php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #46150 File Upload does not work after upgarde from 4.X
Submitted: 2008-09-22 11:46 UTC Modified: 2008-09-22 14:17 UTC
From: npandey2 at sapient dot com Assigned:
Status: Not a bug Package: Filesystem function related
PHP Version: 5.2.6 OS: Windows Server 2003
Private report: No CVE-ID: None
 [2008-09-22 11:46 UTC] npandey2 at sapient dot com
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!

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-09-22 14:17 UTC] tularis@php.net
Sorry, but your problem does not imply a bug in PHP itself.  For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system is not the
appropriate forum for asking support questions.  Due to the volume
of reports we can not explain in detail here why your report is not
a bug.  The support channels will be able to provide an explanation
for you.

Thank you for your interest in PHP.

http://nl.php.net/manual/en/features.file-upload.errors.php
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed May 15 17:01:33 2024 UTC