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, 2022 in JQuery by Edureka
• 13,690 points
693 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, 2022 by Edureka
• 13,690 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 Jun 28, 2022 in JQuery by rajatha
• 7,680 points
16,541 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, 2022 in JQuery by rajatha
• 7,680 points
1,477 views
+1 vote
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,840 points
2,070 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,840 points
5,107 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,840 points
15,712 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,840 points
23,295 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,840 points
3,313 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,840 points
5,102 views
0 votes
1 answer

jquery timepicker cdnjs.cloudflare does not working

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

answered Jun 1, 2022 in JQuery by Edureka
• 13,690 points
1,476 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, 2022 in JQuery by Edureka
• 13,690 points
10,823 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP