I have a program inside a PHP upload image function, but placed on the server upload the Chinese name of the picture, the picture can not be displayed, see the directory of the picture, is uploaded after the image of the directory is garbled. Here's my code, I don't know what went wrong
' Public Function _upload () {
$type = Trim ($_post[' uptype '); $callback = Trim ($_post[' upcallback '); if ($type = = ' image ') {$ext = Getfileext ($_files[' upfile ' [' name ']); if (!file_exists (dir_upload. ') /images/'. Date ("YMD")) {MakeDir (dir_upload, '/images/'. Date ("YMD")); if ($ext = = ' jpg ' | | $ext = = ' png ' | | $ext = = ' gif ' | | $ext = = ' Doc ' | | $ext = = ' txt ' | | $ext = = ' pdf ' | | {$upfile = dir_upload. ') /images/'. Date ("Ymd"). ' /'. Date ("his"). ' _ '. Iconv ("gb2312", "UTF-8", $_files[' upfile ' [' name ']); $upfilepath = '/images/'. Date ("Ymd"). ' /'. Date ("his"). ' _ '. Iconv ("gb2312", "UTF-8", $_files[' upfile ' [' name ']); $upfileurl = Url_upload. ' /images/'. Date ("Ymd"). ' /'. Date ("his"). ' _ '. Iconv ("gb2312", "UTF-8", $_files[' upfile ' [' name ']); Move_uploaded_file ($_files[' upfile ' [' tmp_name '], $upfile); $FILECG = Trim ($_post[' FILECG '); if (! $filecg) {$FILECG = 1; } if ($callback) { Echo '; } die (); }} "echo";
All I use in my HTML is UTF-8 '
How can I change this to upload Chinese file name pictures?
My server is Win2003 is not because the server win2003 is GBK relationship?
Reply content:
I have a program inside a PHP upload image function, but placed on the server upload the Chinese name of the picture, the picture can not be displayed, see the directory of the picture, is uploaded after the image of the directory is garbled. Here's my code, I don't know what went wrong
' Public Function _upload () {
$type = Trim ($_post[' uptype '); $callback = Trim ($_post[' upcallback '); if ($type = = ' image ') {$ext = Getfileext ($_files[' upfile ' [' name ']); if (!file_exists (dir_upload. ') /images/'. Date ("YMD")) {MakeDir (dir_upload, '/images/'. Date ("YMD")); if ($ext = = ' jpg ' | | $ext = = ' png ' | | $ext = = ' gif ' | | $ext = = ' Doc ' | | $ext = = ' txt ' | | $ext = = ' pdf ' | | {$upfile = dir_upload. ') /images/'. Date ("Ymd"). ' /'. Date ("his"). ' _ '. Iconv ("gb2312", "UTF-8", $_files[' upfile ' [' name ']); $upfilepath = '/images/'. Date ("Ymd"). ' /'. Date ("his"). ' _ '. Iconv ("gb2312", "UTF-8", $_files[' upfile ' [' name ']); $upfileurl = Url_upload. ' /images/'. Date ("Ymd"). ' /'. Date ("his"). ' _ '. Iconv ("gb2312", "UTF-8", $_files[' upfile ' [' name ']); Move_uploaded_file ($_files[' upfile ' [' tmp_name '], $upfile); $FILECG = Trim ($_post[' FILECG '); if (! $filecg) {$FILECG = 1; } if ($callback) { Echo '; } die (); }} "echo";
All I use in my HTML is UTF-8 '
How can I change this to upload Chinese file name pictures?
My server is Win2003 is not because the server win2003 is GBK relationship?
I've thought of a way,
is to replace the text
$upfilepath = '/images/'. Date ("Ymd"). ' /'. Date ("his"). Preg_replace (' [^a-z0-9-_.]
i ', ' ', $_files ' upfile ');
Although the picture can be displayed, but very reluctant
This is related to the HTTP protocol. Before uploading, grab a bag to see if your program is GBK or Utf-8-based. Confirm and then go to the corresponding iconv.
Is the server Linux? See if it supports Chinese