Incorrect behavior of "tempnam()" function

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
dpavlo83
Forum Newbie
Posts: 1
Joined: Wed Feb 20, 2008 5:02 am

Incorrect behavior of "tempnam()" function

Post 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!
User avatar
Stryks
Forum Regular
Posts: 746
Joined: Wed Jan 14, 2004 5:06 pm

Re: Incorrect behavior of "tempnam()" function

Post 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
Post Reply