From:             gaoyong at crtvu dot edu dot cn
Operating system: Windows 2k SP4
PHP version:      4.3.4
PHP Bug Type:     *Directory/Filesystem functions
Bug description:  basename() cannot work with Chinese Path name

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 bug report at http://bugs.php.net/?id=26574&edit=1
-- 
Try a CVS snapshot (php4):  http://bugs.php.net/fix.php?id=26574&r=trysnapshot4
Try a CVS snapshot (php5):  http://bugs.php.net/fix.php?id=26574&r=trysnapshot5
Fixed in CVS:               http://bugs.php.net/fix.php?id=26574&r=fixedcvs
Fixed in release:           http://bugs.php.net/fix.php?id=26574&r=alreadyfixed
Need backtrace:             http://bugs.php.net/fix.php?id=26574&r=needtrace
Need Reproduce Script:      http://bugs.php.net/fix.php?id=26574&r=needscript
Try newer version:          http://bugs.php.net/fix.php?id=26574&r=oldversion
Not developer issue:        http://bugs.php.net/fix.php?id=26574&r=support
Expected behavior:          http://bugs.php.net/fix.php?id=26574&r=notwrong
Not enough info:            http://bugs.php.net/fix.php?id=26574&r=notenoughinfo
Submitted twice:            http://bugs.php.net/fix.php?id=26574&r=submittedtwice
register_globals:           http://bugs.php.net/fix.php?id=26574&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=26574&r=php3
Daylight Savings:           http://bugs.php.net/fix.php?id=26574&r=dst
IIS Stability:              http://bugs.php.net/fix.php?id=26574&r=isapi
Install GNU Sed:            http://bugs.php.net/fix.php?id=26574&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=26574&r=float

Reply via email to