Where And How Do I Set The Correct Encoding When Uploading Files Using Xhr
Solution 1:
The parser uses its own encoding as is evident from the API reference.
Try:
mpp = newMultipartParser(request, 100000000);
mpp.setEncoding("UTF-8");
//rest of your code
The reference recommends passing it in constructor though:
mpp = new MultipartParser(request, 100000000, true, true, "UTF-8");
Solution 2:
You can set encoding like this
var oReq = new XMLHttpRequest();
oReq.open("GET", url, true);
// retrieve data unprocessed as a binary string
oReq.overrideMimeType("text/plain; charset=x-user-defined");
Some more info can be found here https://developer.mozilla.org/en-US/docs/DOM/XMLHttpRequest/Using_XMLHttpRequest
Solution 3:
The issue is most likely in your server-side code. Perhaps you are not taking into account that the filename is UTF-8 encoded. Nothing you posted in your question suggests that the name is being sent incorrectly. What you see in Firebug is not necessarily what is being sent. It's very possible that the default encoding being used by Firebug when examining the request does not match the encoding in use by the browser. This would explain why the filename looks garbled in Firebug.
Post a Comment for "Where And How Do I Set The Correct Encoding When Uploading Files Using Xhr"