Suppressed error messages from fopen and fclose so that return format is valid json and added json mime type to headers.
Added correct HTTP response codes from upload.php so that error handling in javascript is triggered.
Merge pull request #634 from unluckypixie/master

Fixed invalid json response format on error.