|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #55491 Add temp directory setting which is used by tempnam(), sys_get_temp_dir(), etc.
Submitted: 2011-08-23 13:18 UTC Modified: 2015-12-07 19:45 UTC
Avg. Score:4.6 ± 0.5
Reproduced:8 of 8 (100.0%)
Same Version:2 (25.0%)
Same OS:0 (0.0%)
From: royanee at yahoo dot com Assigned:
Status: Duplicate Package: PHP options/info functions
PHP Version: 5.3.7 OS:
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.
Bug Type:
From: royanee at yahoo dot com
New email:
PHP Version: OS:


 [2011-08-23 13:18 UTC] royanee at yahoo dot com
Need to be able to set the location of the temporary directory for a VirtualHost using php_admin_value.

This is especially important when you have multiple VirtualHosts that are locked down with open_basedir so that they are not able to read the files in the currently shared temporary directory.

tempnam() and sys_get_temp_dir() should pull the value from this PHP setting so that no code modifications are needed. For backward compatibility, the current default value of the temporary directory can be used to set the default value for the PHP setting.

Test script:
// Make sure to put this line in your vhost config!
// php_admin_value tmp_dir "/www/myvhost/tmp"
// Create a temporary file in the temporary 
// files directory using sys_get_temp_dir()
echo sys_get_temp_dir() . PHP_EOL;
echo tempnam(null, 'Tux') . PHP_EOL;

Expected result:

Actual result:


tmp_dir.patch (last revision 2011-08-23 14:18 UTC by royanee at yahoo dot com)

Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2013-02-26 05:19 UTC] royanee at yahoo dot com
FR #60524 is a duplicate of this request - yet has been incorporated into PHP 5.5.0 
Alpha 5. Thank you to those who pushed for this.

This request can be marked as fixed in 5.5 (or as a duplicate if you're a 
revisionist ;)).
 [2015-12-07 19:45 UTC]
-Status: Open +Status: Duplicate
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Sun Sep 19 07:03:36 2021 UTC