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.