Topic: Plupload does not pick up server side error messages

Having problems with the jsonrpc response messages, they don't seem to get picked up and displayed.

My upload handler can throw all kinds of exceptions and I'd like the exception message to be displayed to the user, but the only message that gets displayed is the generic "IO Error".

Is this a no go?

The json I'm returning is this, for example:

{"jsonrpc" : "2.0", "error" : {"code": 100, "message": "Exception message text"}, "id" : "id"}

I'm also returning an HTTP status code of 500.  Otherwise, Plupload seems to think that everything went well.

Any ideas?

Re: Plupload does not pick up server side error messages

plupload doesn't interpret json, you should parse the text returned by the server using info.response:

FileUploaded: function(up, file, info) {
    alert(info.response);
}

Re: Plupload does not pick up server side error messages

Thanks, I tried that out, it works but in my opinion it's a rather strange behaviour.

I can display the response to the user, but Plupload thinks the upload succeeded.  If I set the HTTP status to 500 in my upload-handler, then the FileUploaded event does not fire, but the Error event will.  In that case, Plupload knows that the file upload did not succeed, but only displays the generic IO error message.

The only way to have the FileUploaded event occur is to return HTTP 200 OK in the upload-handler, but then Plupload thinks everything went well.

I must not be the only one who is having issues with this.  There needs to be away to have custom error messages picked up by Plupload when the upload handler returns an error.

Re: Plupload does not pick up server side error messages

you should return the HTTP status 200 and on the FileUploaded event you should set the file status based on the message returned:

file.status = plupload.FAILED;

Re: Plupload does not pick up server side error messages

Ok, that does help.

Thanks :-)