I'm using latest Dropzone.js release 3.7.1 and PHP script to upload file to server
I'm would like to get message back to drop zone area, on image so i exit with
header('HTTP/1.1 500 Internal Server Error');
header('Content-Type: application/json');
exit();
this display a generic dropzone error on image but if i use
header('HTTP/1.1 500 Internal Server Error');
header('Content-Type: application/json');
exit("My error");
I get "Invalid JSON response from server."
if i use
header('HTTP/1.1 500 Internal Server Error');
header('Content-type: application/json');
exit(json_encode(array('message' => '$msg', code => 500)));
i get "[object Object]"
Does drop zone pass file upload as an array or as a single file?
You can set the response Content-Type to text/plain
and just send the message, or set the Content-Type to application/json
and send {"error": "message"}
.
In both cases you need to send an error header, otherwise Dropzone will not interpret the response as an error:
header('HTTP/1.1 500 Internal Server Error');
header('Content-type: text/plain');
exit("My error");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With