Please enable / Bitte aktiviere JavaScript!
Veuillez activer / Por favor activa el Javascript![ ? ]
How to handle files with Russian names at boot POST? - bug-code.com Q&A

How to handle files with Russian names at boot POST?

0 like 0 dislike
9 views
There is a client which downloads the file with POST request.
The names of files are sometimes in Russian. And when the files arrive on the server - it does not save them.
Can somehow fix it without changing the client?
I understand that it is possible in the client to make changes - such as adding a transliteration before downloading, but at the moment there is only the possibility to change the server part.

The file is saved in a standard manner:
move_uploaded_file($_FILES["filename"]["tmp_name"], $upload_dir_name . '/' . $ClientName . "/" . $ContentTypeDir . '/' . $file_name);


The name of the file actually looks on the server at the time of transfer like this:
=?KOI8-R?B?4dfEz9TY0TIzMi50eHQ=?=
asked by | 9 views

2 Answers

0 like 0 dislike
So, apparently, all the problem is in your:
move_uploaded_file($_FILES["filename"]["tmp_name"], $upload_dir_name . '/' . $ClientName . "/" . $ContentTypeDir . '/' . $file_name);

Where does the $file_name?
Make using transliteration, or even keep with a random hash:
move_uploaded_file($_FILES["filename"]["tmp_name"], $upload_dir_name . '/' . $ClientName . "/" . $ContentTypeDir . '/' . MyRandomGenerator::getString());
answered by
0 like 0 dislike
The file is saved in a standard manner:


It's not standard. Since no one else does, just because it's a security hole. Not that hole, and straight darissa. If the client will give you the file with any name (of course saarnisaari, because the point of a server nil) "../../../index.php"for example, you and save?

Do some "\\md5($fileName . \\random_int(0, \\PHP_INT_MAX))" and do not invent to itself problems.
answered by
Welcome to Bug-code Q&A, where you can ask questions and receive answers from other members of the community.

24.8k questions

46.2k answers

0 comments

12.7k users

24,788 questions
46,220 answers
0 comments
12,715 users