ID: 28395
Comment by: anthony dot parsons at manx dot net
Reported By: si at bananas dot hopto dot org
Status: Open
Bug Type: *General Issues
Operating System: Windows 2000 Apache2
PHP Version: 5.0.0RC2
New Comment:
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).
Previous Comments:
------------------------------------------------------------------------
[2004-05-19 20:36:00] 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-14 12:41:55] 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> </p>";
echo "<p><h2>Upload image to Server.</h2></p>
<p> </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.
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=28395&edit=1