Problems when uploading a file named in russian

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
mcorlan
Forum Newbie
Posts: 2
Joined: Fri Mar 24, 2006 9:43 am

Problems when uploading a file named in russian

Post by mcorlan »

I am trying to preserve after the upload the orifinal name of the file (in my case could be Russian or English).
I tried to set UTF-8 for internal/external mbstring and also in the page which is cotaining the form I am using
UTF-8 encoding.

Despise all of these, all my uploads with files in Russian are done with the named f***ed up;

Could any one help me to resolve this?

As a side note, I did the same test on yahoo mail and gmail. Guess what? Just gmail handle correct the file name.

regards,
Mihai
User avatar
Weirdan
Moderator
Posts: 5978
Joined: Mon Nov 03, 2003 6:13 pm
Location: Odessa, Ukraine

Post by Weirdan »

post your code. This simple snippet gave me the correct results:

Code: Select all

header("Content-type: text/html;charset=utf8");
    if(count($_FILES)) {
        var_dump($_FILES);
    }
    echo <<<HTML
        <form method='post' enctype='multipart/form-data'>
            <input type='file' name='file'/>
            <input type='submit' />
        </form>
HTML;
For tests I used file named "Мысли.doc"

Note that to save the file on server under original name your server's filesystem must support utf8 filenames (which isn't the case for the vast majority of hosts)

Another note: I have no mbstring input/output conversions in place
mcorlan
Forum Newbie
Posts: 2
Joined: Fri Mar 24, 2006 9:43 am

Post by mcorlan »

Unfortunately the problem is this: the file system is saving the file name with incorrect characters. If I copied this chars in a html page and I set the encoding utf8, it will be displayed OK. But if I am looking at the file in explorer/totalcomander it will be incorrect.

This what I end up when is uploading: фйцуф.jpg
And this is what I was uploaded: фйцуф.jpg

I have tried both on my Windows Xp instalation (Apache + PHP5) and Linux. The same result I get.
Post Reply