Below I will summarize the php utf8 encoding to upload a Chinese file name garbled solution. If you have such problems, please refer.
The Code is as follows: |
Copy code |
<? Php If (isset ($ _ FILES ['file']) { $ Upload = 'upload/'. $ _ FILES ['file'] ['name']; If (is_uploaded_file ($ _ FILES ['file'] ['tmp _ name']) { // The iconv function solves the problem of garbled Chinese names of uploaded files, but it does not advocate that the file names are Chinese characters, especially in unix/linux environments. When you want to output the files, you need to change them back, iconv ('gb2312', UTF-8 ', $ upload) If (! Move_uploaded_file ($ _ FILES ['file'] ['tmp _ name'], iconv ('utf-8', 'gb2312', $ upload ))){ Echo 'failed '; } Else { Echo 'success '; } } Else { Echo 'failed '; } } ?> /***** Application of iconv functions: string iconv (string in_charset, string out_charset, string str) * In_charset: Format of the input file * Out_charset: Format of the output file * Str: file path *****/ |