jquery easyupload plugin not uploading pdf files

0 votes

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);
		} 

 

Jun 3 in JQuery by Edureka
• 13,640 points
20 views

1 answer to this question.

0 votes

In this case, we need to check

upload_max_filesize and 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();
}
answered Jun 3 by Edureka
• 13,640 points

Related Questions In JQuery

0 votes
1 answer

Jquery validation plugin - TypeError: $(...).validate is not a function

The "$(...). validate is not a function" ...READ MORE

answered 10 hours ago in JQuery by rajatha
• 4,060 points
29 views
0 votes
1 answer

jQuery Validation plugin. Two custom rules not working

validation plugin works according to the name attribute and ...READ MORE

answered Jun 20 in JQuery by rajatha
• 4,060 points
13 views
0 votes
1 answer

How to check if a jQuery plugin is loaded?

Hello @kartik, for the plugins that doesn't use ...READ MORE

answered Apr 28, 2020 in JQuery by Niroj
• 82,720 points
698 views
0 votes
1 answer

Uncaught ReferenceError:Karma: jQuery is not defined

Hii @kartik, You first have to load jQuery ...READ MORE

answered May 12, 2020 in JQuery by Niroj
• 82,720 points
2,830 views
0 votes
1 answer

Uncaught TypeError: Cannot read property 'msie' of undefined - jQuery tools

Hello, Use the following script tag in your ...READ MORE

answered Apr 28, 2020 in JQuery by Niroj
• 82,720 points
8,283 views
0 votes
1 answer

Uncaught Error: Bootstrap's JavaScript requires jQuery

Hello @kartik, You have provided wrong order for ...READ MORE

answered Apr 28, 2020 in JQuery by Niroj
• 82,720 points
15,143 views
0 votes
1 answer

How to make Bootstrap popover Appear/Disappear on hover instead of click?

Hello @kartik, Set the trigger option of the popover to hover instead ...READ MORE

answered May 12, 2020 in JQuery by Niroj
• 82,720 points
1,184 views
0 votes
1 answer

How to enable Bootstrap tooltip on disabled button?

Hii @kartik, You can wrap the disabled button ...READ MORE

answered May 12, 2020 in JQuery by Niroj
• 82,720 points
3,025 views
0 votes
1 answer

jquery timepicker cdnjs.cloudflare does not working

jQuery Timepicker can parse the most used ...READ MORE

answered Jun 1 in JQuery by Edureka
• 13,640 points
26 views
0 votes
1 answer

addClass and removeClass in jQuery - not removing class

What happens is that your close button ...READ MORE

answered Jun 2 in JQuery by Edureka
• 13,640 points
26 views
webinar REGISTER FOR FREE WEBINAR X
Send OTP
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP