Reputation: 13
Hi I'm having problems with the file uploading in CodeIgniter with files that have latin characters, when I upload them the name that I echo is correctly shown but in the folder where I upload the file the name changes, for example I have this File:
"Tour al Volcán del Totumo y a los Manglares.docx"
When I echo the name it's shown like that but in the folder where the file is stored is shown like:
"Tour al Volcán del Totumo y a los Manglares.docx"
I've looked everywhere and I haven't been able so solve this, also I have made configurations such as the utf-8 charset and all that stuff.
Upvotes: 0
Views: 1325
Reputation: 99533
Files in folders are also shown in a specific character encoding. Which encoding that is, depends on the operating system.
Depending on the operating system, multiple bugs are possible.
On linux: Things are stored as UTF-8, but whatever you are using to view the folder (GUI, terminal, sftp client, ftp client, whatever) is set to default to something like latin-1 / ISO-8559-1 and showing it incorrectly, even though the files are correctly stored.
On Mac: Files are somehow being double-UTF-8 encoded in your application. This means the filename was already in UTF-8, and you are calling utf8_encode on the string again (which is bad!)
On windows: PHP only supports the ANSI-filesystem api on windows. There is literally no way (without using COM) to store files with unicode filenames, because the input string is always treated as if it was CP-1252, and converted to UTF-8. If the characters you are using all exist in CP-1252, you can convert your UTF-8 input to CP-1252 by using iconv or mb_convert_encoding.
More information: http://evertpot.com/filesystem-encoding-and-php (my blog)
Upvotes: 1