【发布时间】:2019-01-16 19:47:40
【问题描述】:
我正在使用easyupload jquery
源:https://github.com/fater/jquery-easyupload
我正在尝试上传文件(图片、doc、docx 上传完美),但 pdf 显示错误但它没有解释错误。
我的代码:
elseif ($type == "upload_file") {
$target_dir = $_SERVER['DOCUMENT_ROOT']."/admin2/uploads/images/";
$target_file = $target_dir . basename($_FILES["file"]["name"]);
$uploadOk = 1;
$imageFileType = strtolower(pathinfo($target_file,PATHINFO_EXTENSION));
// Check if image file is a actual image or fake image
if (file_exists($target_file)) {$data['status'] = "error"; $data['msg'] = $BNL->msg("הקובץ עם השם הזה כבר קיים במערכת.");}
elseif ($_FILES["file"]["size"] > 5000000) {$data['status'] = "error"; $data['msg'] = $BNL->msg("המגבלה של העלאת קובץ היא 5MB");}
elseif($imageFileType != "pdf" && $imageFileType != "doc" && $imageFileType != "docx" ) {$data['status'] = "error"; $data['msg'] = $BNL->msg("הקבצים המותרים הם PDF, DOC, DOCX");}
else {
if (move_uploaded_file($_FILES["file"]["tmp_name"], $target_file)) {
$data['msg'] = $BNL->msg("הקובץ ". basename( $_FILES["file"]["name"]). " הועלה בהצלחה.", true);
$_SESSION['file'] = basename( $_FILES["file"]["name"]);
} else {
//$data['msg'] = $BNL->msg("סליחה, הייתה בעיה בהעלאת הקובץ.");
$data['msg'] = $_FILES['file']['error']; // Print "1"
}
}
echo json_encode($data);
}
我两天都想不通是什么问题。
谁能帮帮我,在此先感谢。
【问题讨论】:
-
你检查我的答案了吗?
-
@KhoaTruongDinh 还没有,我现在想检查,但你能解释得更好吗?
标签: javascript php jquery