php function Move_uploaded_file () the solution to the error in moving Chinese files

Source: Internet
Author: User

In the WinDOS Chinese system, the required parameters if the Chinese must be GBK encoded

1. Use Iconv () to convert the character set code as follows

$target _pt = './uploads/'. Uniqid (). ' -'. $images [' name '];//windows supports Chinese name upload $upload_file_pt = Iconv ("UTF-8", "GB2312", $target _pt); if (!move_uploaded_file ($images [' Tmp_name '], $upload _file_pt)) {$GLOBALS [' error_message '] = ' upload failed '; return;}

2, take the name directly with Uniqid () to get the name, with PathInfo () to obtain the suffix code as follows

$ext =pathinfo ($_files[' Avatar ' [' Name '], pathinfo_extension); $target = ' uploads/'. Uniqid (). '. $ext, if (!move_uploaded_file ($_files[' Avatar ' [' Tmp_name '], $target)) {$GLOBALS [' error_message '] = ' failed to upload file '; return;}

php function Move_uploaded_file () the solution to the error in moving Chinese 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.