ID: 32644 Updated by: [EMAIL PROTECTED] Reported By: tck at tcknetwork dot com -Status: Open +Status: Feedback Bug Type: Filesystem function related Operating System: WinXP(SP2) PHP Version: 5.0.4 New Comment:
Please try using this CVS snapshot: http://snaps.php.net/php5-latest.tar.gz For Windows: http://snaps.php.net/win32/php5-win32-latest.zip Also add this to be first line in your script handling the upload: error_reporting(E_ALL); ini_set('display_errors', 1); Previous Comments: ------------------------------------------------------------------------ [2005-04-09 17:17:08] tck at tcknetwork dot com This happens both if I use zend optimizer or not (I doubted it could be a possible source of problems. Note as well that my Apache (2.0.53, using php as a module) root is on D:\Server if it may help. ------------------------------------------------------------------------ [2005-04-09 16:53:29] tck at tcknetwork dot com 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 this bug report at http://bugs.php.net/?id=32644&edit=1