1

In my php code I want to upload files with Farsi names (e.g. نام.pdf) but the uploaded file name gets garbled after that. I am on a Win 7 (64bit) machine using WAMP as my development environment. I know that this problem is related to my working environment because the code works fine on a Linux production machine. How can I convert the $uploaded['name']to the supported encoding on the Windows machine? Please help me.

Ali Erfani
  • 682
  • 1
  • 11
  • 27

2 Answers2

1

The problem is fixed on PHP 7.1, but if you intend to stick to the current version of the PHP you're using, there's a fix for Windows OS.

Please check the thread that I posted some time ago, and the solution I found (read the FINAL EDIT of my original post) :

Solution to UTF-8 files names and PHP move_uploaded_file

0

There is a PHP function called: utf8_encode. http://www.w3schools.com/php/func_xml_utf8_encode.asp

Also, you can make sure you have this line:
PHP Way:
header('Content-Type: text/html; charset=utf-8');

HTML Way:
<meta charset="utf-8">

odedta
  • 2,430
  • 4
  • 24
  • 51
  • i have used utf8_encode but the problem remains. The charset is also set to UTF-8 in the header. – Ali Erfani Jul 02 '15 at 22:26
  • Can you send a link of any farsi pdf file so I can test things for you? I also have RTL-language filenames and I never had this problem before. – odedta Jul 03 '15 at 12:09
  • I don't have a problem with the content of the files. The content don't change. My problem is only with the file name. You can rename a file to this (نام) and test the file. – Ali Erfani Jul 03 '15 at 13:14