#41989 [Fbk->Csd]: move_uploaded_file & relative path
| From: | tony2001@php.net | Date: | Thu, 19 Jul 2007 15:50:09 +0000 |
| Subject: | #41989 [Fbk->Csd]: move_uploaded_file & relative path | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-115241@lists.php.net to get a copy of this message | ||
ID: 41989
Updated by: tony2001@php.net
Reported By: gerome dot fournier at infomaniak dot ch
-Status: Feedback
+Status: Closed
Bug Type: Filesystem function related
Operating System: Debian sarge
PHP Version: 5.2.3
New Comment:
Assuming the patch is ok.
Fixed in CVS.
Previous Comments:
------------------------------------------------------------------------
[2007-07-13 10:07:24] tony2001@php.net
But please try this patch first.
http://dev.daylessday.org/diff/bug41989.diff
------------------------------------------------------------------------
[2007-07-13 09:57:43] tony2001@php.net
Please try with prefork MPM.
------------------------------------------------------------------------
[2007-07-13 09:46:23] gerome dot fournier at infomaniak dot ch
Description:
------------
The function move_uploaded_file does not work if the destination
path is a relative path. The function returns TRUE, but the file is
not moved at all.
If I replace the following line:
$dest_file = "./tmp/test.txt";
by:
$dest_file = getcwd() . "/tmp/test.txt";
then everything works as expected. In the reproduce code, I provide
the HTML form used to upload a file, and the PHP code to process the
uploaded file. PHPINFO of the server running this script is available
here:
http://imu120.infomaniak.ch/phpinfo.php
Reproduce code:
---------------
<html>
<form enctype="multipart/form-data" METHOD="POST"
action="upload.php">
<input type="file" name="import_file"/>
<input type="submit" name="submit"/>
</form>
</html>
<?php
if (is_uploaded_file($_FILES["import_file"]["tmp_name"])) {
$dest_file = "./tmp/test.txt";
if (move_uploaded_file($_FILES["import_file"]["tmp_name"],
$dest_file)) {
// check the uploaded file has really been moved or not
if (! file_exists($dest_file))
echo "ERROR: uploaded file not moved as $dest_file";
else
echo "OK: uploaded file moved as $dest_file";
}
}
?>
Expected result:
----------------
OK: uploaded file moved as ./tmp/test.txt
Actual result:
--------------
ERROR: uploaded file not moved as ./tmp/test.txt
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=41989&edit=1