views:

520

answers:

2

I am using uploadify and the file name retrieved from $_FILES["fileData"]["name"] on server side is in utf8. It may contain chinese or japanese characters. After the following codes run,

$tempFileWithPath = $_FILES['Filedata']['tmp_name'];
$destFile = $_FILES['Filedata']['name'];

$destFileWithPath=myUtility::getFileRepositoryPath().'/'.$destFile;
move_uploaded_file($tempFileWithPath,$destFileWithPath);

For those files using chinese or japanese file name, I used filezilla ftp client (which supports utf8 file name) and browser the folder and found that they all become ?????. Of course, other files using english-only file name do not have this problem.

I am using php 5.2.9 and the server is linux on a shared hosting.

Is it true that all file-related functions in PHP have problems supporting utf8? Or my problem is related to other issues?

+1  A: 

Try to decode destination file name using iconv function.

For example:

$destFile = ("UTF-8", "ISO-8859-1", $_FILES['Filedata']['name']); // decodes to ISO-8859-1

ARTstudio
thank you so much for your reply.
bobo
you are wellcome.
ARTstudio
+2  A: 

The target filesystem has to support the encoding as well - this may have nothing to do with uploadify or PHP at all.

Peter Bailey
I think you are right, I checked that the server is using ANSI_X3.4-1968 rather than utf-8 as its default charset, maybe the ftp client knows about this from the server, so it will not display in utf8, resulting in some question marks.
bobo