note 93256 modified in function.tempnam by danbrown
| From: | danbrown@php.net | Date: | Mon, 31 Aug 2009 03:48:43 +0000 |
| Subject: | note 93256 modified in function.tempnam by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-160072@lists.php.net to get a copy of this message | ||
Watch out using a blank $dir as a "trick" to create temporary files in the system
temporary directory.
<?php
$tmpfname = tempnam('', 'FOO'); // not good
?>
If an open_basedir restriction is in effect, the trick will not work. You will get a warning message
like
Warning: tempnam() [function.tempnam]: open_basedir restriction in effect.
File() is not within the allowed path(s): (/var/www/vhosts/example.com/httpdocs:/tmp)
What works is this:
<?php
$tmpfname = tempnam(sys_get_temp_dir(), 'FOO'); // good
?>
--was--
Watch out using a blank $dir as a "trick" to create temporary files in the system
temporary directory.
<?php
$tmpfname = tempnam('', 'FOO'); // not good
?>
If an open_basedir restriction is in effect, the trick will not work. You will get a warning message
like
Warning: tempnam() [function.tempnam]: open_basedir restriction in effect.
File() is not within the allowed path(s): (/var/www/vhosts/domain.com/httpdocs:/tmp)
What works is this:
<?php
$tmpfname = tempnam(sys_get_temp_dir(), 'FOO'); // good
?>
http://php.net/manual/en/function.tempnam.php