Page 1 of 1

Incorrect behavior of "tempnam()" function

Posted: Wed Feb 20, 2008 5:08 am
by dpavlo83
Hi guys, I have following issue:
tempnam (string $dir, string $prefix) function doesn't try to create temporary file in $dir directory, instead it's just put temporary file into system temp folder which is c:\windows\temp.
IIS has all rights to $dir, I know this because fopen() works fine (I can create files with fopen).
I'm using IIS+PHP 5.0.5.
Looking forward for any suggestions!

Re: Incorrect behavior of "tempnam()" function

Posted: Wed Feb 20, 2008 7:39 am
by Stryks
I would suspect that the $dir parameter isn't arriving as expected.

A brief look at the manual page for tempnam and the comments underneath show an issue with relative paths. As per those comments, try the following.

Code: Select all

$file = tempnam(getcwd() . $dir, $prefix);
Cheers