php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #47681 System TMP dir ignored in file uploads
Submitted: 2009-03-16 23:00 UTC Modified: 2009-03-17 11:04 UTC
Votes:4
Avg. Score:4.2 ± 0.8
Reproduced:3 of 3 (100.0%)
Same Version:2 (66.7%)
Same OS:1 (33.3%)
From: ulrich at cs dot auckland dot ac dot nz Assigned:
Status: Open Package: Apache2 related
PHP Version: 5.2.9 OS: win32 only - Win XP Pro
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: ulrich at cs dot auckland dot ac dot nz
New email:
PHP Version: OS:

 

 [2009-03-16 23:00 UTC] ulrich at cs dot auckland dot ac dot nz
Description:
------------
File upload under Apache 2.2.8 and 2.2.11 produces an empty temporary file name and an UPLOAD_ERR_NO_TMP_DIR error in $_FILES[<userfile>]['error']. In the case of the machine concerned, Apache and PHP run off the D: drive whereas the temporary directories reside under C:.

Rebooting the entire system sometimes resolves the problem temporarily, but it then reappears. This does not always work, however. Repeat "uploads" occasionally cause the server to crash.

Setting the temporary directory explicitly using upload_tmp_dir provides a workaround.

Default windows system tmp dir variables are set as:

TEMP=C:\WINDOWS\TEMP
TMP=C:\WINDOWS\TEMP



Reproduce code:
---------------
<?php
      if (count($_FILES) > 0) { 
        echo "<h1>Response page</h1>";
        echo "<h2>\$_ENV</h2>";
        foreach ($_ENV as $name => $value) echo $name."=".htmlentities($value)."<br/>";
        echo "<h2>\$_FILES</h2>";
        foreach ($_FILES["myFile"] as $fileProperty => $filePropertyValue) {
            echo $fileProperty."=".$filePropertyValue."<br>";
        }
      } else { 
      ?>
        <h1>Form</h1>
        <form action="fu.php" method="post" enctype="multipart/form-data">
          Please enter a file: <input type="file" name="myFile">
          <input type="submit" value="Submit file for processing">
        </form>
      <?php
      }
?>

Expected result:
----------------
$_ENV
...
TEMP=C:\WINDOWS\TEMP
TMP=C:\WINDOWS\TEMP
...

$_FILES
name=figure1-e.pdf
type=application/pdf
tmp_name=C:\WINDOWS\Temp\php981.tmp
error=0
size=50452

Actual result:
--------------
$_ENV
...
TEMP=C:\WINDOWS\TEMP
TMP=C:\WINDOWS\TEMP
...

$_FILES
name=figure1-e.pdf
type=
tmp_name=
error=6
size=0

Patches

Add a Patch

Pull Requests

Add a Pull Request

 
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Sat Feb 29 10:01:27 2020 UTC