I’m using PHP 5.3 with MSSQL-Server 2005 and MSSQL-Server (PDO) driver from MS.
I recently struggled a litte bit with the new version of the driver and the charset it uses to pass data from the DB. So I decided to configure my whole application to UTF-8 to avaoid these kind of issues in the future.
So I changed the database to use unicode-datatypes, configured the HTML header and set up Eclipse to save the codefiles in UTF-8 format. Also I added the correspondig accept-charset tag to all my HTML forms. So far so good. Everything worked as expected but now I’m stuck with a new issue.
I wrote a simple script that can upload files using a HTML form and save them on my webserver (Windows Server 2003 with IIS6). This worked perfectly until I switched to UTF. When I upload a file with special chars in the filename, these are not saved correctly. Uplading a File named “ÄÖÜ.txt” ends up with a file named “ÄÖÜ.txt” on my webserver. This can be a pain because all further processing of these files depends on hyperlinks which are not correct any more.
I tried to several possible solutions like this:
$isMoved = move_uploaded_file($_FILES['uploadedFile']['tmp_name'],"myFolder". utf8_encode($_FILES['uploadedFile']['name']));
But I’m always ending upth eiher having a correct file name on the server’s filesystem or the other was around.
Anyone an idea? 😀
Thanks in advance
Daniel
if I am not completely wrong, the filename is encoded in UTF-8. Just decode it using mb_convert_encoding():
BurninLeo