php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #28395 Uploading of files failure
Submitted: 2004-05-14 12:41 UTC Modified: 2004-09-16 01:00 UTC
Votes:10
Avg. Score:4.4 ± 0.8
Reproduced:7 of 9 (77.8%)
Same Version:6 (85.7%)
Same OS:4 (57.1%)
From: si at bananas dot hopto dot org Assigned:
Status: No Feedback Package: *General Issues
PHP Version: 5.0.0RC2 OS: Windows 2000 Apache2
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: si at bananas dot hopto dot org
New email:
PHP Version: OS:

 

 [2004-05-14 12:41 UTC] si at bananas dot hopto dot org
Description:
------------
When uploading files, the first attempt will always fail, repeating the process (same script) it will upload ok.

It seem that $_FILES is not getting filled with the filename of the upload or something around that.





Reproduce code:
---------------
	if ($_POST[Submit] == "Upload")
	{
		$uploaddir = "c:\\program files\\apache group\\apache2\\htdocs\\images\\";
		$uploadfile = $uploaddir . $_FILES['userfile']['name'];
		if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile))
		{
			echo "<h2><center>Upload Successful</center></h2>";
		}
		else
		{
			sleep(2);
			$uploaddir = "c:\\program files\\apache group\\apache2\\htdocs\\images\\";
			$uploadfile = $uploaddir . $_FILES['userfile']['name'];
			if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile))
			{
				echo "<h2><center>Upload Successful - Attempt 2</center></h2>";
			}
			else
			{
				echo "<font face=\"Arial, Helvetica, sans-serif\"><h2>
				Upload Failed - Possible Bad File!</h2><p>&nbsp;</p>";
				echo "<p><h2>Upload image to Server.</h2></p>
				<p>&nbsp;</p>
				<form action=\"$_SERVER[PHP_SELF]\" method=post enctype=\"multipart/form-data\">
				<input type=\"hidden\" name=\"MAX_FILE_SIZE\" value=\"90000\">
				<p>File: <input type=FILE name=\"userfile\"></p>
				<input type=Submit name=\"Submit\" value=\"Upload\">
				</form>";
			}
		}
	}

Expected result:
----------------
File to be uploaded on first attempt.

Actual result:
--------------
First upload will fail, second time it will suceed.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-05-19 20:36 UTC] anthony dot parsons at manx dot net
Similar problem with RC1 using WinXP + Apache 2, as well as a May 14th build. I haven't been able to make uploads work at all.

Here's a more basic testcase, for me the print_r always returns an empty array (on RC1 and later) whether a file is uploaded or not:

<?php
if (isset ($_POST['submit']))
	print_r ($_FILES);
?>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
<input type="file" name="file1" />
<input type="submit" name="submit" />
</form>
 [2004-05-23 02:33 UTC] anthony dot parsons at manx dot net
Not just limited to PHP 5: I'm seeing this problem with PHP 4.3.7-dev as well (build date May 22 2004 22:12:55).
 [2004-05-23 06:44 UTC] webmaster at script-tease dot net
I'm using php4.3.7-dev as well and encounter no problem with file uploads...

http://cpi.merseine.nu:8080/files.php
http://cpi.merseine.nu:8080/files.phps
 [2004-06-12 21:37 UTC] anthony dot parsons at manx dot net
I think I found the problem: open_basedir seems to be blocking PHP from accessing the directory where the temporary uploaded files are stored. The only way I could get uploads to work with an open_basedir set is by having upload_tmp_dir set to a path inside that.
 [2004-06-20 23:37 UTC] DelislMa at CollegeSherbrooke dot qc dot ca
I tested uploads with php5-200406081430.
In php.ini, my upload_tmp_dir was empty, as PHP is supposed
to use the system default. But it did not.
Setting upload_tmp_dir to /tmp solved the problem for me.
 [2004-09-08 05:48 UTC] curt@php.net
Please provide the original form you are using to post to this script.
 [2004-09-16 01:00 UTC] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 16:01:28 2024 UTC