According to this comment
on the PHP manual pages, the
function is affected by the
Quoting from the mentioned comment about
Remember, that open_basedir affects this function. You will get an error:
Warning: tmpfile() [function.tmpfile]: open_basedir restriction in effect. File(/var/tmp) is not within the allowed path(s): ....blablabla =)
Ok, I decided to test, so I altered my php.ini adding this restriction:
open_basedir = D:\htdocs
After restarting php, I checked with
was in effect, it was...
Fine, then lets try to run this script which should produce the mentioned warning message since my
, (as shown in
) is now outside the
, and I would then not expect
to be working.
$temp = tmpfile();
fwrite($temp, "writing to tempfile");
echo 'x:'.fread($temp, 1024);
sleep(10); // sleep 10 seconds
(According to the PHP documentation the temporary file created by
will automatically be deleted again when the script ends so
was added so I could check whether the temporary file was created or not while the script was running.)
Now comes the weird part... Strangely, I get absolutely no warning message when running the above script. On the contrary,
seems to be totally unaffected by the
setting! And when I look in
I indeed see the a file
appear and vanish when the script starts and stops. But
is not within
which I has set as the
restriction and where the script is running.
My question is therefore: When is
tmpfile() restricted by
open_basedir, and when not?
Environment: PHP 5.2.6 / Apache / Microsoft Windows Server 2003
If it is of interest, the reason for the above question is that I am trying to figure out why some users are having trouble with the PEAR Spreadsheet_Excel_Writer
on some hosts.