I am using Dropzone.js for my website and am getting stuck on sending a response through server side.
This is my code.
upload.php
<?php
header("Content-Type:application/json");
$target_dir = '../assets/uploads/';
$target_file = $target_dir . basename($_FILES['filetoupload']['name']);
$imagetype = strtolower(pathinfo($target_file , PATHINFO_EXTENSION));
$sizeoffile = $_FILES['filetoupload']['size'];
if( $sizeoffile > 3000000){
$response = 'File is Too Big. Max 3MB !';
$status = 417;
goto respond;
}
else{
$response = 'checking';
$status = 200;
goto respond;
}
respond:
$data = array(
'status' => $status,
'responseText' => $response ,
'size' => $sizeoffile
);
echo json_encode($_FILES);//just for checking
?>
uploader.js
var myDropzone = new Dropzone('#myDropZone',{
/* ... */
init: function(){
this.on("success", function(file, response){
console.log(file);
console.log(response);
});
}
});
The JSON response from the server side to javascript on console looks like this.
Have a look at this.
Thanks for any help!
While if I choose an image of size less than 2Mb It is working
This is another image have a look