0

I am uploading files which names are in cyrillic. But when I open the directory where I have saved this files , its names arent the same and are composed by very strange caracters РћР±СЏРІР°. My php file is encoded in UTF - 8 here is the code of the uploading:

if(move_uploaded_file($_FILES['picture']['tmp_name'] , 'test'.DIRECTORY_SEPARATOR.$_FILES['picture']['name'])){

                    echo "File uploaded successfully";

}

Here is all the code of the PHP file:

http://pastebin.com/eVL7QHFF

Rufinus
  • 29,200
  • 6
  • 68
  • 84
Montoolivo
  • 137
  • 2
  • 3
  • 15
  • 2
    you should not use the orginal file name, this leads to many security and other problems. see http://stackoverflow.com/a/17866898/151097 – Rufinus Sep 07 '14 at 08:26
  • I am making a school project and they want it this way . So how to conserve the original name of the file when they are written in cyrillic? – Montoolivo Sep 07 '14 at 08:30
  • no wonder the internet is full of crapy sites with security hohles big as ....., if they learn you sh** in school. :( – Rufinus Sep 07 '14 at 08:36
  • but for the sake of the question... you could try to `utf8_decode` the filename. depends on your system setting. – Rufinus Sep 07 '14 at 08:37
  • And how to do the utf8_decode ? – Montoolivo Sep 07 '14 at 08:51
  • `if(move_uploaded_file($_FILES['picture']['tmp_name'] , 'test'.DIRECTORY_SEPARATOR.utf8_decode($_FILES['picture']['name']))){` – Rufinus Sep 07 '14 at 09:05

1 Answers1

1

Worked for me

$fileName = iconv("utf-8","cp1251",  $fileName);
Andrey Danilov
  • 6,194
  • 5
  • 32
  • 56