|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2008-09-22 14:17 UTC] tularis@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Dec 12 22:00:02 2025 UTC |
Description: ------------ We upgraded out Data Hosting platform from PHP Version 4.4.2 to 5.2.6 and after that the script to upload files keeps failing. The relevent settings in PHP.ini file open_basedir = NOT Set safe_mode = On file_uploads = On upload_tmp_dir = C:\Windows\Temp Cannot submit URL as the installation is curerntly at the integration environment Reproduce code: --------------- PHP Script : <html> <head><title>DataUpload per PHP</title></head> <body> <? $file_dir = "./files/"; $userfile = $_FILES['userfile']['name']; $tmp = $_FILES['userfile']['tmp_name']; $err = $_FILES['userfile']['error']; $size = $_FILES['userfile']['size']; echo "phpversion: " . phpversion() . "<br />"; echo "fileuploads: " . get_cfg_var('file_uploads') . "<br />"; echo "upload_tmp_dir: " . get_cfg_var('upload_tmp_dir') . "<br />"; echo "file_dir: " . $file_dir . "<br />"; echo "userfile: " . $userfile . "<br />"; echo "tmp :" . $tmp . "<br /><br />"; if ($_POST['submit'] == "Senden") { if ($_FILES["file"]["error"] > 0){ echo "Return Code: " . $_FILES["file"]["error"] . "<br />"; } elseif (file_exists($file_dir.$userfile)) { die ("File does not exists!"); } elseif (move_uploaded_file($tmp, $file_dir.$userfile)) { die ("Data file $userfile copied"); } else{ die ("Data Upload failed!"); }} else { ?> <form enctype="multipart/form-data" action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post"> <h3>Data File: <input name="userfile" type="file" /> </h3> <input type="submit" name="submit" value="Senden" /> </form> <?php } ?> </body> </html> Expected result: ---------------- PHP Script : phpversion: 5.2.4 fileuploads: 1 upload_tmp_dir: C:\Windows\Temp file_dir: ./files/ userfile: 2.txt tmp :C:\WINDOWS\Temp\php8487.tmp Data file 2.txt copied Actual result: -------------- PHP Script : phpversion: 5.2.4 fileuploads: 1 upload_tmp_dir: C:\Windows\Temp file_dir: ./files/ userfile: 2.txt tmp : Return Code: 6 Data Upload failed!