最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Dropzone debug and ajax messages from PHP - Stack Overflow

programmeradmin1浏览0评论

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?

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?

Share Improve this question asked Nov 15, 2013 at 9:02 al404ITal404IT 1,4184 gold badges25 silver badges58 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 9

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");
发布评论

评论列表(0)

  1. 暂无评论