ID: 26574
Updated by: [EMAIL PROTECTED]
Reported By: gaoyong at crtvu dot edu dot cn
-Status: Open
+Status: Assigned
Bug Type: *Directory/Filesystem functions
Operating System: Windows 2k SP4
PHP Version: 4.3.4
-Assigned To:
+Assigned To: moriyoshi
New Comment:
This problem appears to be caused by the wrong usage of
IsDBCSLeadByte().
Previous Comments:
------------------------------------------------------------------------
[2003-12-09 22:51:12] gaoyong at crtvu dot edu dot cn
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
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=26574&edit=1