From: tck at tcknetwork dot com Operating system: WinXP(SP2) PHP version: 5.0.4 PHP Bug Type: *Directory/Filesystem functions Bug description: move_uploaded_file() relative path
Description: ------------ The move_uploaded_file() use the root of the hard disk in some special cases instead of using the relative path from the script. So far require() is not affected by this problem. I think it is just this function that handles not properly the path. Reproduce code: --------------- My file system is built like this : D:\Data (directory) D:\Web\data (directory << note the ressemblance) D:\Web\test\up.php (my script) My script contains the following : <? $f=$_FILES["myfile"]["tmp_name"]; @move_uploaded_file($f,"../data/demo.jpg"); ?> <form enctype="multipart/form-data" method="post" action="<?=$_SERVER["PHP_SELF"]; ?>"> <input type="file" name="myfile"> <input type="submit" value="upload"> </form> Expected result: ---------------- When I send a file, I expect it to be uploaded into dirname("D:\Web\test\up.php")."../data/demo.jpg" it means "D:\Web\data\demo.jpg". In fact when I submit a file with my script twice, the following happens : 1st submit : File uploaded into "D:\Data\demo.jpg" (using the root instead of relative path) 2nd submit : File uploaded into "D:\Web\data\demo.jpg" (working as expected only if the file "D:\Data\demo.jpg" exists) Actual result: -------------- Actually the PHP developer can fix this bug by changing the upload line @move_uploaded_file($f,"../data/demo.jpg"); by @move_uploaded_file($f,dirname($_SERVER["SCRIPT_FILENAME"])."/../data/demo.jpg"); note that if the directory D:\Data does not exists, the function will place the file properly into D:\Web\data -- Edit bug report at http://bugs.php.net/?id=32644&edit=1 -- Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=32644&r=trysnapshot4 Try a CVS snapshot (php5.0): http://bugs.php.net/fix.php?id=32644&r=trysnapshot50 Try a CVS snapshot (php5.1): http://bugs.php.net/fix.php?id=32644&r=trysnapshot51 Fixed in CVS: http://bugs.php.net/fix.php?id=32644&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=32644&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=32644&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=32644&r=needscript Try newer version: http://bugs.php.net/fix.php?id=32644&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=32644&r=support Expected behavior: http://bugs.php.net/fix.php?id=32644&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=32644&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=32644&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=32644&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=32644&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=32644&r=dst IIS Stability: http://bugs.php.net/fix.php?id=32644&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=32644&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=32644&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=32644&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=32644&r=mysqlcfg