jquery easyupload plugin not uploading pdf files
jquery easyupload plugin not uploading pdf files
I am using easyupload jquery
Src: https://github.com/fater/jquery-easyupload
I am trying to upload files ( images,doc,docx uploaded perfectly) but pdf showing me error but its not explaning the error.
My CODE:
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);
I cant figure it out what the problem I am trying to fix it for two days.
Any one can help me please, thanks in advance.
@KhoaTruongDinh Not yet, I want to check now but you can explain it better?
– Maor Ben Lulu
yesterday
1 Answer
1
In this case, we need to check
upload_max_filesize and post_max_size.
upload_max_filesize
post_max_size
http://php.net/manual/en/features.file-upload.php
<?php
try
if (empty($_FILES))
new Exception('$_FILES array is empty.');
else
if (isset($_FILES['file']) && !empty($_FILES['file']))
//Check error code
#https://github.com/zendframework/zend-validator/blob/master/src/File/Upload.php#L25
;
catch (Throwable $exception)
echo $exception->getMessage();
https://github.com/zendframework/zend-validator/blob/master/src/File/Upload.php#L25
Read more: $_FILE upload large file gives error 1 even though upload_max_size is bigger than the file size
tried with the code you gave me and always getting "Exceeded filesize limit." even if the limit 9999999999999999 and the file sizing 4.2MB
– Maor Ben Lulu
yesterday
Did you check the limit in your php.ini? Try with smaller file < 2MB.
– Khoa TruongDinh
yesterday
ini_get('post_max_size'); response "8M"
– Maor Ben Lulu
yesterday
How about
upload_max_filesize?– Khoa TruongDinh
yesterday
upload_max_filesize
2M, that's that problem for sure...
– Maor Ben Lulu
yesterday
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.
Did you check my answer?
– Khoa TruongDinh
yesterday