php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #47999 tempnam() fails to create file
Submitted: 2009-04-17 03:34 UTC Modified: 2009-10-07 22:37 UTC
Votes:3
Avg. Score:4.7 ± 0.5
Reproduced:3 of 3 (100.0%)
Same Version:3 (100.0%)
Same OS:3 (100.0%)
From: phpbug at danf dot oib dot com Assigned: garretts (profile)
Status: Not a bug Package: Filesystem function related
PHP Version: 5.2.9 OS: win32 only - Windows Server 2003
Private report: No CVE-ID: None
 [2009-04-17 03:34 UTC] phpbug at danf dot oib dot com
Description:
------------
tempnam() does not create a temporary file, and silently fails. This worked fine in PHP 5.2.3, but starting failing in 5.2.6 (or somewhere in between). It still does not work in 5.2.8 or 5.2.9-1.

I've tested with both the IIS module (php5isapi.dll) and php-cgi.exe, with the same results.

open_basedir is off.


Reproduce code:
---------------
<?php
$tempnam = tempnam('','random') or die("Can't create tmpfile.\n");
echo "Successfully created $tempnam.\n";
?>


Expected result:
----------------
Successfully created D:\temp\ran1E42.tmp.

Actual result:
--------------
Can't create tmpfile.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-04-17 10:45 UTC] jani@php.net
Check the permissions on the temporary files path (TEMP / TMP, or whatever it is set to in your system) or pass a path that is writable.
 [2009-04-17 16:41 UTC] phpbug at danf dot oib dot com
Yes, D:\temp has Modify permission for Everyone. Remember, this worked in PHP 5.2.3 on the same server, so it can't be a permissions issue, assuming the method the tempnam() function uses to determine which directory to use was consistent from 5.2.3 forward.
 [2009-10-07 22:37 UTC] garretts@php.net
I'm unable to reproduce this with PHP 5.2.9-2 and PHP 5.3.
I used your repro code, and tried: 

the command line:

   Successfully created C:\Users\garretts\AppData\Local\Temp\ran81CC.tmp.

from a web page:

   Successfully created C:\Windows\Temp\ranBFA6.tmp. 


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Apr 23 05:01:28 2024 UTC