Phputf8 encoding garbled characters appear in the uploaded Chinese file name _ PHP Tutorial

Source: Internet
Author: User
Phputf8 encoding garbled characters appear in the uploaded Chinese file name. Next I will summarize the solutions for garbled characters in Chinese file names uploaded by phputf8 encoding. if you have such problems, please refer. The code is as follows: Copy the code? Phpif (isset ($ _ FILES [below I will summarize the php utf8 encoding to upload a Chinese file name garbled solution. if you have such problems, refer.
The code is as follows:

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

*****/

Utf8 encoding for uploading Chinese file names garbled solution, if you have such problems, refer to reference. The code is as follows? Php if (isset ($ _ FILES ['...

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.