예제 #1
0
function uploadFileoczj1($fileInfo, $path, $destination, $allowExt = array(""), $maxSize = 1048576000000.0)
{
    //判断错误号
    if ($fileInfo['error'] == UPLOAD_ERR_OK) {
        //文件是否是通过HTTP POST方式上传上来的
        if (is_uploaded_file($fileInfo['tmp_name'])) {
            //上传文件的文件名,只允许上传jpeg|jpg、png、gif、txt的文件
            //$allowExt=array("gif","jpeg","jpg","png","txt");
            $ext = getExtczj($fileInfo['name']);
            $uniqid = getUniqidNameczj();
            //$destination=$path."/".pathinfo($fileInfo['name'],PATHINFO_FILENAME)."_".$uniqid.".".$ext;
            //$filename001=explode(".", $fileInfo['name']);
            //$filename001_1=$filename001[0];
            //$destination=$path."/".$filename001_1."_".$uniqid.".".$ext;
            if (!in_array($ext, $allowExt)) {
                if ($fileInfo['size'] <= $maxSize) {
                    if (move_uploaded_file($fileInfo['tmp_name'], $destination)) {
                        $mes = "文件上传成功";
                    } else {
                        $mes = "文件移动失败";
                    }
                } else {
                    $mes = "文件过大";
                }
            } else {
                $mes = "非法文件类型";
            }
        } else {
            $mes = "文件不是通过HTTP POST方式上传上来的";
        }
    } else {
        switch ($fileInfo['error']) {
            case 1:
                $mes = "超过了配置文件的大小";
                break;
            case 2:
                $mes = "超过了表单允许接收数据的大小";
                break;
            case 3:
                $mes = "文件部分被上传";
                break;
            case 4:
                $mes = "没有文件被上传";
                break;
        }
    }
    return $mes;
}
예제 #2
0
require_once 'function/czj_upload_function.php';
$public_function = new public_function();
$blog_userid = $_SESSION['UID'];
if ($_SESSION['UID'] == null || $_SESSION['UID'] == 0) {
    echo "<script>location.href='../admin.php'</script>";
}
$xmid = str_replace(" ", "", $_GET['xmid']);
$zlselectid = str_replace(" ", "", $_GET['zlselectid']);
$url = str_replace(" ", "", $_GET['url']);
$url1 = str_replace(" ", "", $_GET['url1']);
$page = str_replace(" ", "", $_GET['page']);
$path = "attache";
if ($_POST['types'] == "fileupload") {
    $fileInfo = $_FILES['file_upload'];
    $xm_fj_name = $_FILES["file_upload"]["name"];
    $ext = getExtczj($fileInfo['name']);
    $uniqid = getUniqidNameczj();
    //$xm_fj_address=$path."/".pathinfo($fileInfo['name'],PATHINFO_FILENAME)."_".$uniqid.".".$ext;
    //$xm_fj_address=$path."/".pathinfo($fileInfo['name'],PATHINFO_FILENAME)."_".$uniqid.".".$ext;
    $filename001 = explode(".", $fileInfo['name']);
    $filename001_1 = $filename001[0];
    //过滤掉上传文件名称中的空格
    $filename001_1 = str_replace(" ", "", $filename001_1);
    $xm_fj_address = $path . "/" . $filename001_1 . "_" . $uniqid . "." . $ext;
    $zlselectid = str_replace(" ", "", $_POST['zlselectid']);
    $url = str_replace(" ", "", $_POST['url']);
    $xm_id = str_replace(" ", "", $_POST['xmid']);
    $userid = str_replace(" ", "", $_POST['userid']);
    $xm_fj_uploadtime = CURRENT_TIME;
    $mes = uploadFileoczj1($fileInfo, $path, $xm_fj_address);
    //$mes="";