I am using Fine Uploader 3.7.0 in a project with Chrome and Firefox and it works fine, but with Internet Explorer 10 the files are uploaded correctly but the user always get the "Upload failed" error message, even with the demo tests:
<script>
$(document).ready(function() {
var errorHandler = function(event, id, fileName, reason) {
qq.log("id: " + id + ", fileName: " + fileName + ", reason: " + reason);
};
var myUploader = new qq.FineUploader({
element: $('#basicUploadButton')[0],
multiple: false,
callbacks: {
onError: errorHandler
},
request: {
endpoint: '/fineupload/receiver'
}
});
});
</script>
<div class="fineUploader">
<span>Please upload your files for automated process.</span>
<div id="basicUploadButton" class="upload-btn"></div>
</div>
<br />
<div><a href="#" onclick="window.close()">Close Window</a></div>
I debugged the servlet and I see that I am sending this:
writer.print("{\"success\": true, \"uuid\": \"" + requestParser.getUuid() + "\", \"originalFileName\": \"" + requestParser.getFilename() + "\"}");
so I think that the JSON I am supposed to get is correct.
Any ideas why can this be failing with IE10? I also tried with the compatibility modes and didn't work.
Updated: Console log:
[FineUploader 3.7.0] Error when attempting to parse xhr response text (SyntaxError: Invalid character)
id: blog.jpg, fileName: Upload failure reason unknown, reason: [object XMLHttpRequest]
Thanks!
The problem was due to the JSON response I was creating in Java.
Looking at the Network tab in IE10 developer tools (thanks Ray for the advice) I get:
{"error": "java.io.FileNotFoundException: C:\data\uploads\fd9b5240-5661-4f07-a216-7a76b2250b00_C:\folder\blog.jpg (The filename, directory name, or volume label syntax is incorrect)"}
I was using
writer.print("{\"success\": true, \"uuid\": \"" + requestParser.getUuid() + "\", \"originalFileName\": \"" + requestParser.getFilename() + "\"}");
Instead of that
JSONObject json = new org.json.JSONObject();
json.put("success", true);
json.put("uuid", requestParser.getUuid());
json.put("originalFileName", requestParser.getFilename());
writer.print(json.toString());
works fine with every browser.
Anyway, I needed to avoid the file name that IE10 manages (C:\folder\blog.jpg) so I had to use
json.put("originalFileName", getCorrectFileName(requestParser.getFilename()));
with getCorrectFilename(String s) removing the "C:\folder\" part.