Radley Sustaire
Radley Sustaire

Reputation: 3399

Plupload 2 does not give error when it should

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):

enter image description here

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".

enter image description here

How do I make "OK":0 fire the error event - or at least not act like the upload was successful?

Upvotes: 0

Views: 182

Answers (1)

Ferry Kranenburg
Ferry Kranenburg

Reputation: 2635

You should return HTTP status 500 from the server.

See also this thread.

Upvotes: 1

Related Questions