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: 2020-08-23 04:23 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: cmb (profile)
Status: No Feedback Package: Apache2 related
PHP Version: 5.2.9 OS: win32 only - Win XP Pro
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [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

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2020-08-11 10:39 UTC] cmb@php.net
-Status: Open +Status: Feedback -Assigned To: +Assigned To: cmb
 [2020-08-11 10:39 UTC] cmb@php.net
I cannot reproduce the reported behavior with current PHP-7.3
running via mod_php.  Can anybody else reproduce this with any of
the actively supported PHP versions[1]?

[1] <https://www.php.net/supported-versions.php>
 [2020-08-23 04:23 UTC] php-bugs at lists dot php dot net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Re-Opened". Thank you.
 
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Tue Dec 01 13:01:47 2020 UTC