Example #1
0
    $targetDir = "../" . $_SESSION["upfolder"] . "/" . getSavePicPath() . "/";
    $targetFile = date('Ymd') . time() . substr($FILEa['name'], -4, 4);
    $realFile = $targetDir . $targetFile;
    if (function_exists('move_uploaded_file')) {
        move_uploaded_file($FILEa['tmp_name'], $realFile);
        if (app_watermark == 1) {
            imageWaterMark($targetDir . $targetFile, getcwd(), app_waterlocation, app_waterfont);
        }
        if (app_ftp == 1) {
            uploadftp($targetDir, $targetFile);
        }
        if ($action == "xht") {
            echo "{'err':'" . $errm . "','msg':'" . app_installdir . replaceStr($upfileDir, "../../", "") . $targetFile . "'}";
        } else {
            die("<script>parent.document.getElementById('pic').value='" . "http://" . $_SERVER["HTTP_HOST"] . '/' . "cms" . '/' . replaceStr($upfileDir, "../../", "") . $targetFile . "'</script>上传成功!");
        }
    } else {
        @copy($FILEa['tmp_name'], $realFile);
        if (app_watermark == 1) {
            imageWaterMark($targetDir . $targetFile, getcwd(), app_waterlocation, app_waterfont);
        }
        if (app_ftp == 1) {
            uploadftp($targetDir . $targetFile);
        }
        if ($action == "xht") {
            echo "{'err':'" . $errm . "','msg':'" . app_installdir . replaceStr($upfileDir, "../../", "") . $targetFile . "'}";
        } else {
            die("<script>parent.document.getElementById('pic').value='" . replaceStr($upfileDir, "../../", "") . $targetFile . "'</script> 上传成功!");
        }
    }
}
Example #2
0
        $fname = date('Ymd') . time() . '.' . $ext;
    }
    if (function_exists('move_uploaded_file')) {
        @move_uploaded_file($FILEa['tmp_name'], $updir . $fname);
    } else {
        @copy($FILEa['tmp_name'], $updir . $fname);
    }
    $thumbjs = '';
    if ($MAC['upload']['watermark'] == 1) {
        imageWaterMark($updir . $fname, getcwd(), $MAC['upload']['waterlocation'], $MAC['upload']['waterfont']);
    }
    if ($id == 'd_pic' && $MAC['upload']['thumb'] == 1) {
        $thumbst = img2thumb($updir . $fname, "../../" . $thumbdir . $fname, $MAC['upload']['thumbw'], $MAC['upload']['thumbh']);
        if ($thumbst) {
            $thumbjs = '<script>parent.document.getElementById("d_picthumb").value="' . $thumbdir . $fname . '"</script>';
        }
    }
    if ($path == 'vod' && $action != "xht" && $MAC['upload']['ftp'] == 1) {
        uploadftp($showdir, $fname);
        if ($thumbst) {
            uploadftp($thumbdir, $fname);
        }
    }
    if ($action == "xht") {
        echo '{"status":"true","err":"' . $errm . '","msg":"' . $MAC['site']['installdir'] . $showdir . $fname . '"}';
    } elseif ($action == 'uploadify') {
        echo '{"status":"true","msg":"ok","file":"' . $showdir . $fname . '"}';
    } else {
        echo '<script>parent.document.getElementById("' . $id . '").value="' . $showdir . $fname . '"</script>上传成功![ <a href="#" onclick="history.go(-1);return false;">重新上传</a> ]' . $thumbjs;
    }
}
Example #3
0
function savepic($url, $path, $thumbpath, $fname, $flag, &$msg)
{
    $res = false;
    $pathlink = '../' . $path;
    $thumblink = '../' . $thumbpath;
    if (!is_dir($pathlink)) {
        mkdirs($pathlink);
    }
    if (!is_dir($thumblink)) {
        mkdirs($thumblink);
    }
    $st = strrpos($url, "/");
    $tmpfpath = substring($url, $st, 0);
    $tmpfname = rawurlencode(substring($url, strlen($url) - $st, $st + 1));
    $url = $tmpfpath . "/" . $tmpfname;
    $errsize = 3;
    $byte = getPage($url, "utf-8");
    $bytelen = strlen($byte);
    $size = round($bytelen / 1024, 2);
    fwrite(fopen($pathlink . $fname, "wb"), $byte);
    $img_mime = array('image/gif', 'image/jpeg', 'image/png', 'image/bmp');
    $re = getimagesize($pathlink . $fname);
    if (!in_array($re['mime'], $img_mime)) {
        $msg = "(<font color=red>该文件可能是无效图片,跳过保存</font>)<a target=_blank href=" . $url . ">查看</a>";
        $status = false;
    } else {
        if ($flag == 'vod') {
            if ($GLOBALS['MAC']['upload']['watermark'] == 1) {
                imageWaterMark($pathlink . $fname, MAC_ROOT . '/inc/common/', $GLOBALS['MAC']['upload']['waterlocation'], $GLOBALS['MAC']['upload']['waterfont']);
            }
            if ($GLOBALS['MAC']['upload']['thumb'] == 1) {
                $thumbst = img2thumb($pathlink . $fname, $thumblink . $fname, $GLOBALS['MAC']['upload']['thumbw'], $GLOBALS['MAC']['upload']['thumbh']);
            }
            if ($GLOBALS['MAC']['upload']['ftp'] == 1) {
                uploadftp($path, $fname);
                if ($thumbst) {
                    uploadftp($thumbpath, $fname);
                }
            }
        }
        $msg = "PicView:<a href='" . $pathlink . $fname . "' target='_blank'>" . $pathlink . $fname . "</a> <font color=red>" . $size . "</font>Kb";
        $status = true;
    }
    unset($img_mime, $re);
    return $status;
}
Example #4
0
function savepic($picUrl, $picpath, $picfile)
{
    global $wjs;
    if ($picfile == "") {
        echo "file参数不正确";
        $status = false;
    } else {
        mkdirs(dirname($picpath));
        $imgsbyte = getPage($picUrl, "utf-8");
        $size = round(strlen($imgsbyte) / 1024, 3);
        if (strlen($imgsbyte) < 100 || strpos("," . $imgsbyte, "<html") > 0 || strpos("," . $imgsbyte, "<HTML") > 0) {
            echo "保存失败:<font color=red>非正常的图片文件,请编辑数据复制图片地址在浏览器中访问测试下是否正常</font>图片地址是: <a target=_blank href=" . $picUrl . ">" . $picUrl . "</a><br>";
            $status = false;
        } else {
            fwrite(fopen($picpath . $picfile, "wb"), $imgsbyte);
            if (app_watermark == 1) {
                imageWaterMark($picpath . $picfile, getcwd() . "\\editor", app_waterlocation, app_waterfont);
            }
            if (app_ftp == 1) {
                uploadftp($picpath, $picfile);
            }
            echo "<a target=_blank href=" . $picpath . $picfile . ">" . $picpath . $picfile . "</a>保存成功:<font color=red>" . $size . "Kb</font><br>";
            $status = true;
        }
        if (!isN($wjs)) {
            echo "<script>parent.dstate=true;</script>";
        }
    }
    return $status;
}