1

I am getting filename from file obj in javascript and sending the same to server using AJAX.

var uploadFile = document.getElementById("uploadFile");
var filename = uploadFile.files[0].name;

The problem is non English characters found in filename such as 'çõ' and the chars converted to "�". I also set "Content-Type=text/html; charset=UTF-8" in the page.

How can I solve this problem?

Note: This problem occurs only in windows laptops

6
  • 1
    Where do the chars become unreadable? If it's in the server, it's a server problem, not a js problem.
    – bfavaretto
    Oct 10, 2013 at 20:17
  • The filename converted to unreadable in js and the converted value sending to server. I have seen in Developer Console -> Network -> Headers
    – Magesh
    Oct 10, 2013 at 20:20
  • UTF-8 needs to be all the way through your system -- the files you read need to be in UTF-8, as do the actual program files. The database encoding too. And the encoding specified in the content-type. If you have a mismatch of encoding types anywhere through your system, it can result in this kind of error.
    – Spudley
    Oct 10, 2013 at 21:03
  • I think this is not a server side problem. Because, if it's a server side problem, the encoding issue will occur for all users. But, this problem occurs only for some users.
    – Magesh
    Oct 10, 2013 at 21:07

1 Answer 1

0

I solved the problem:

filename = unescape(encodeURIComponent(filename));

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.