|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #44972 Feature Request: overriding sys_get_tmp_dir
Submitted: 2008-05-12 15:30 UTC Modified: 2013-03-22 15:30 UTC
Avg. Score:4.6 ± 0.6
Reproduced:15 of 15 (100.0%)
Same Version:8 (53.3%)
Same OS:3 (20.0%)
From: timtowdi at yahoo dot com Assigned: reeze (profile)
Status: Closed Package: *General Issues
PHP Version: 5.2.6 OS: FreeBSD
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: timtowdi at yahoo dot com
New email:
PHP Version: OS:


 [2008-05-12 15:30 UTC] timtowdi at yahoo dot com
On a server with open_basedir in effect, sys_get_temp_dir() still uses the default TMPDIR environment variable (which in this case is '/tmp').  This effectively renders sys_get_temp_dir useless for me, and there is no way to override it.

It would be EXTREMELY useful to be able to set the default temp directory from an ini directive, such as the session temp dir and the uploaded files temp dir.


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2008-05-12 15:46 UTC]
One is already possible:

About the temp directory, you will have to teach your ISP how to configure php correctly. Not having the tmp dir in the open_basedir lists (and having only one global tmp dir instead of per user) is so wrong.

However a temp_dir ini setting (settable per vhost) would be nice. Let see what's the other say (I'm not a fan of ENV variables ;).
 [2010-09-07 05:44 UTC] brian at macserve dot net
1. the suggested php.ini setting for "uploaded files" has ZERO effect on the original requestors report. the directory returned by the sys_get_tmp_dir() function cannot be overriden from within PHP or php.ini; only where uploaded files are placed can be overridden which only coincidentally is the same when you do NOT define upload_tmp_dir in php.ini.

the original request stands as a valid critique.

2. your url is missing an "el" at the end of manual.

3. The security environment of the original request is interesting and perhaps up for debate, but is not relevant to this discussion.

There may be valid technical reasons for locating TMPDIR for PHP to another location other than the TMPDIR environment variable that comes into Apache. Perhaps temp files for PHP need to live on a different disk for performance and/or security reasons.

Being able to define this with a php.ini setting is completely reasonable.

4. Sorry to be a noodge, but this request over 2 years old and not resolved?

./main/php_open_temporary_file.c : php_get_temporary_directory() needs just a little bit of code it looks like.

 [2011-03-14 19:35 UTC] royanee at yahoo dot com
sys_get_tmp_dir() and tempnam() are both affected on my system. However, using SetEnv TMPDIR in the Apache configuration does not work. getenv('TMPDIR') returns the expected result, but sys_get_tmp_dir() is unaffected. Please allow for a default temporary directory option so that I can switch my virtual hosts to that and resolve all of the temporary file issues (not simply uploads).
 [2011-12-30 11:54 UTC] jan dot kellermann at werk21 dot de
Please just add a flag to this function for loading the default tmp-dir (cached in 
static var) or get it actually from env TMPDIR. 

There ARE situations you dont want to save your user-temp-files to your sys-temp-
dir. Then you can use SetEnv in apache-conf.
 [2013-03-22 15:30 UTC]
Implemented #60524
 [2013-03-22 15:30 UTC]
-Status: Open +Status: Closed -Package: Feature/Change Request +Package: *General Issues -Assigned To: +Assigned To: reeze
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Jul 13 23:01:29 2024 UTC