|   | php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login | 
| 
 PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits              [2003-12-10 00:55 UTC] moriyoshi@php.net
  [2004-01-22 04:38 UTC] moriyoshi@php.net
 | |||||||||||||||||||||||||||
|  Copyright © 2001-2025 The PHP Group All rights reserved. | Last updated: Fri Oct 31 04:00:01 2025 UTC | 
Description: ------------ if the parameter of basename() contain Chinese path name like this "e:\????\2.jpg",the function can not work. The HTML contain the path "e:\????\2.jpg" First, I copy the upload temp file from "c:\winnt\temp" to the cache path("d:\oems\....\cach"), Secondly, I parse the HTML content that user submiting,and getting the image "SRC" like "e:\????\2.jpg", third, using basename() to get the filename(2.jpg) but the function return "e:\????\2.jpg" When The path name doesn't contain Chinese Character and space,it can work well. Reproduce code: --------------- function Picstr_handle($s) { ...... $s=stripslashes($s); $tmpImg = explode("SRC=\"",$s); $tmpImg1 = explode("\"></IMG>",$s); ...... for ($i =1; $i< count($tmpImg); $i++) { $sourcefilepath[$i] = explode("\"></IMG>",$tmpImg[$i]); $destfilepath[$i] = $ServerRootPath."/exam/image/".$QuestionPathName[$QuestionType]; if (!is_dir($destfilepath[$i])) {mkdir($destfilepath[$i],0);} $destfilepath[$i] .= "/".$InputUser; if (!is_dir($destfilepath[$i])) {mkdir($destfilepath[$i],0);} $destfilepath[$i] .= "/".date("Ymd",time()); if (!is_dir($destfilepath[$i])) {mkdir($destfilepath[$i],0);} $destfilepath[$i] .= "/" .substr(md5(basename($sourcefilepath[$i][0])),2,8) .substr(basename($sourcefilepath[$i][0]),strlen(basename($sourcefilepath[$i][0]))-4,4); $sourcefilepath[$i][0] =$ServerRootPath."/exam/image/cache/".basename($sourcefilepath[$i][0]); if(!is_file($destfilepath[$i])) { if (!copy($sourcefilepath[$i][0],$destfilepath[$i])) { echo "???Ƶ???" .$sourcefilepath[$i][0]." ʧ??...<br>" ;break;exit(); } if (is_file($sourcefilepath[$i][0])) {unlink($sourcefilepath[$i][0]);} } } Expected result: ---------------- Warning: copy(D:/oems/teachingcenter_test/webroot/exam/image/cache/E:\????\2.JPG): failed to open stream: Invalid argument in D:\oems\teachingcenter_test\webroot\exam\datainput\insert.html on line 77 ???Ƶ???D:/oems/teachingcenter_test/webroot/exam/image/cache/E:\????\2.JPG ʧ??... Actual result: -------------- no warning