Fixed invalid json response format on error.

If there is a problem with the file handling the resulting error messages are output corrupting the JSON response sent to the browser I have added "@" to suppress these messages so the response from the PHP is valid JSON.

I have also added a Json mime-type header to the output as it's good practice.