|   | php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login | 
| 
  [2007-02-19 01:13 UTC] stloukal at programator dot cz
 Description: ------------ Hello, I have a problem with move_uploaded_file() function which doesn't move the uploaded file. No errors or warnings are thrown, only false is returned. Problem occurs only if target directory is RELATIVELY addressed and it is named "tmp". It seems, that this is the same problem: http://bugs.php.net/bug.php?id=32456 Reproduce code: --------------- $path = '../../tmp/'.$_FILES['soubor']['name']; // this is not the system tmp directory echo 'uploaded: '.$_FILES['soubor']['tmp_name'].' = '.(int)file_exists($_FILES['soubor']['tmp_name']); move_uploaded_file($_FILES['soubor']['tmp_name'], $path); echo ' moved: '.$path.' = '.(int)file_exists($path); Expected result: ---------------- uploaded: /home/chroot/tmp/phpcLIB4C = 1 moved: ../../tmp/galerie_2001_image001jpg.jpg = 1 Actual result: -------------- uploaded: /home/chroot/tmp/phpcLIB4C = 1 moved: ../../tmp/galerie_2001_image001jpg.jpg = 0 PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits             | |||||||||||||||||||||||||||||||||||||
|  Copyright © 2001-2025 The PHP Group All rights reserved. | Last updated: Fri Oct 31 05:00:02 2025 UTC | 
Hello, here is working code that demonstrates described bug. I append some configuration that may be interesting for you. Configuration: Safe mode: off $_SERVER[SCRIPT_FILENAME]: /var/www/web/tuzemsko/krtek/admin/gallery_test.php real path of the script: /home/chroot/home/krtek/web/tuzemsko/www/admin/gallery_test.php /var/www/web/tuzemsko/krtek is a symbolic link to /home/chroot/home/krtek/web/tuzemsko/www/. httpd.conf: <Directory "/var/www/web/tuzemsko/krtek"> php_admin_value upload_tmp_dir /home/chroot/tmp/ php_admin_value open_basedir /var/www/web/tuzemsko/krtek/:/home/chroot/tmp/:/home/chroot/home/krtek/web/ </Directory> Directory /home/chroot/home/krtek/web/tuzemsko/tmp/ has 0777 permissions. ------------------------------------------------------- Script: <?php // *************** UPLOAD FOTKY *************** if ($_REQUEST['load_pic']) { $name = 'galerie_'.$_FILES['soubor']['name']; $path = '../../tmp/'.$name; echo 'uploaded: '.$_FILES['soubor']['tmp_name'].' = '.(int)file_exists($_FILES['soubor']['tmp_name']); $res = move_uploaded_file($_FILES['soubor']['tmp_name'], $path); echo ' moved: '.$path.' = '.(int)file_exists($path); } // *************** UPLOAD FOTKY KONEC *************** echo ' <form action="'.$_SERVER['PHP_SELF'].'" method="post" enctype="multipart/form-data"> <input type="hidden" name="MAX_FILE_SIZE" value="200000" /> <input type="file" name="soubor" /> <input type="submit" value="Save" /> <input type="hidden" name="load_pic" value="true" /> </form> '; ?> Everything worked fine with 5.1.2 version.hello m using his code to move a file from temp folder to targe folder its running successfully on local host but not working on free hosting server can any one help me in giving a valid path for moving file. if(!move_uploaded_file($_FILES["file"]["tmp_name"],"/upload/".$_FILES["file"]["name"] )) { echo "file can not be moved"; } else { echo "file moved"; } }