#41989 [NEW]: move_uploaded_file & relative path
From: gerome dot fournier at infomaniak dot ch
Operating system: Debian sarge
PHP version: 5.2.3
PHP Bug Type: Filesystem function related
Bug description: move_uploaded_file & relative path
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 bug report at http://bugs.php.net/?id=41989&edit=1
--
Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=41989&r=trysnapshot44
Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=41989&r=trysnapshot52
Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=41989&r=trysnapshot60
Fixed in CVS: http://bugs.php.net/fix.php?id=41989&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=41989&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=41989&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=41989&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=41989&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=41989&r=support
Expected behavior: http://bugs.php.net/fix.php?id=41989&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=41989&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=41989&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=41989&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=41989&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=41989&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=41989&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=41989&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=41989&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=41989&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=41989&r=mysqlcfg
Thread (4 messages)
- gerome dot fournier at infomaniak dot ch