An error occurred while uploading the file name in Chinese. how can this problem be solved?

Source: Internet
Author: User
Failed to upload file name in Chinese $ dir = $ _ SERVER ['document _ root']. & quot;/uploads/& quot; & nbsp; // rename the uploaded file $ filename =$ _ FILES [$ my failed to upload the file name in Chinese
$ Dir = $ _ SERVER ['document _ root']. "/uploads /";
// Rename the uploaded file
$ Filename = $ _ FILES [$ myfile] ['name'];
// $ Filename = mb_convert_encoding ($ _ FILES [$ myfile] ['name'], "UTF-8", "GBK ");
// $ Filename = iconv ("gb2312", "UTF-8", $ _ FILES [$ myfile] ['name']);
// Echo $ filename; die;
// The function for uploading files: move_uploaded_file (temporary directory of the file, directory of the file to be loaded)
If (move_uploaded_file ($ _ FILES [$ myfile] ['tmp _ name'], $ dir. $ filename )){
// Decompress and upload the file
Dp_unzipfile ($ filename, $ path );
// Echo "file uploaded successfully ";
} Else {
Echo "failed to upload file ";
}

------ Solution --------------------
PHP code
In windows, the path should be D: \ WebService \ doc.juren9.com \ uploads \ room Aston .zip Linux: #/WebService/doc.juren9.com/uploads/room Aston .zip.gz
------ Solution --------------------
Discussion
$ Dir = $ _ SERVER ['document _ root']. "/uploads /";
// Rename the uploaded file
$ Filename = $ _ FILES [$ myfile] ['name'];
// $ Filename = mb_convert_encoding ($ _ FILES [$ myfile] ['name'], "UTF-8", "GBK ");
// $ Filename ......

------ Solution --------------------
In Chinese, print $ _ FILES [$ myfile ].
------ Solution --------------------
This is the file for uploading images in my project. use it with your help !!
PHP code
/*** Function: * image Upload * parameter description: * $ imgpath: FILE variable * return value: * 1: $ imgpath complete Image path after image upload is successful * 2: false failed to upload image * 2: false failed to upload image * version: * August 5 update on January 1, 1st */function upload_image ($ imgpath) {$ name = $ imgpath ["name"]; $ tmp_name = $ imgpath ["tmp_name"]; $ type = $ imgpath ["type"]; $ size = $ imgpath ["size"]; $ uploadfile = ".. /index/upload_image /". $ imgpath ['name']; // time (). "_". upload location $ maxsize = 500*1024; // maximum allowed file size if ($ name = "") {// file name Empty echo "script" alert ('select the image file to upload first! '); Window. history. back (); script ";} if ($ size> $ maxsize) {// exceeds the specified size echo" script alert ('upload file size cannot exceed 500 kb! '); Window. history. back (); script "; exit;} if (move_uploaded_file ($ tmp_name, $ uploadfile) return $ uploadfile; else if (copy ($ tmp_name, $ uploadfile )) return $ uploadfile; else return false ;} // The upload_image function calls this function on the page where the handler needs to upload images. // if it is not a page, do not forget to include this file on that page $ photo = $ _ FILES ['photo ']; upload_image ($ photo);?>
------ Solution --------------------
Just repeat the name.

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.