php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #30925 HTTP POST file upload problem
Submitted: 2004-11-29 01:30 UTC Modified: 2004-11-29 02:39 UTC
From: himself at zhwau dot net Assigned:
Status: Not a bug Package: Unknown/Other Function
PHP Version: 5.0.2 OS: Windows XP
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: himself at zhwau dot net
New email:
PHP Version: OS:

 

 [2004-11-29 01:30 UTC] himself at zhwau dot net
Description:
------------
When trying to POST upload a file with the proper <FORM> tag, including the proper enctype and all (but without size restriction with MAX_FILE_SIZE as in manual example), the receiving script defined in ACTION results in move_uploaded_file() returning TRUE even though the file wasn't moved at all.

Odd things happen when you try reloading the ACTION target page which makes Firefox repost the data - the second time around, the PHP script moves the file, even though it is assigned a different temp file name. Then everything works fine.

Could this be the result of a write-behind process for the filesystem which makes move_uploaded_file() return true even if it didn't move the actual file?

Reproduce code:
---------------
<?php
  // The receiving script
  $ime = $_FILES['slika']['name'];
  if (move_uploaded_file($_FILES['slika']['tmp_name'], $ime)) {
    // Here i execute the code responsible for handling the file
  }
  else {
    // Report that the upload failed
  }
?>

Expected result:
----------------
Should execute the 'ELSE' part of the sentence, since the move_upload_file() should return true in the case of a failed file move - unless it only detects whether or not the tmp_name file exists.

Actual result:
--------------
First time around, the move_uploaded_file() returns true (meaning the temp file exists) but the file isn't moved to $ime (i.e. the same dir where the script is executed).

If you reload the page (and repost the same data), the tmp_name changes while all stays the same and the file is successfully moved.

Apache 2.0.52 / PHP 5.0.2 running on WinXP SP2

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-11-29 02:39 UTC] edink@php.net
Submitted twice.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon May 20 06:01:34 2024 UTC