Reputation: 3399
I'm using plupload to upload some files using AJAX. Under "Create upload handler" in the Plupload Documentation it states that you can return {"OK": 0}
in cause of an error.
I am trying to get this to work. I would like to throw an error when the server rejects the upload. I have my code throwing {"OK": 0}
immediately, and it is working. Here is the network response (edit.php):
With this, Plupload is still firing the FileUploaded
event and is NOT firing the Error
event. I also do not see any way to access the returned JSON string (aka, the value of "OK") inside the FileUploaded event.
var uploader = new plupload.Uploader({ ... });
uploader.init();
// When a file has been uploaded
uploader.bind('FileUploaded', function(up, file) {
log('FileUploaded', up, file);
});
// Display errors if they occurr
uploader.bind('Error', function(up, err) {
log('Error', up, err);
});
Here is the result, notice the event text is "FileUploaded" instead of "Error".
How do I make "OK":0
fire the error event - or at least not act like the upload was successful?
Upvotes: 0
Views: 182
Reputation: 2635
You should return HTTP status 500 from the server.
See also this thread.
Upvotes: 1