I’m trying to use tmpfile() but is returning false for me.
I can’t use sys_get_temp_dir() as I’m on PHP5.1.6 as posters on similar issues have suggested but if I test my upload_tmp_dir (is this the same value as sys_get_temp_dir()?) with is_writable() it returns true.
Apparently according to responses the tmp directory is likely to be different to the upload_tmp_dir. The problem is none of the methods of finding out the tmp directory work:
$_ENV['tmp'], $_ENV['temp'] and $_ENV['tmpdir'] are empty. Also the following code won’t work as tempnam() fails,presumably the same reason tmpfile() does.
$temp=tempnam(__FILE__,'');
if (file_exists($temp)) {
unlink($temp);
return dirname($temp);
}
Has anyone got any more suggestions?
Could it be a server configuration issue?
Thanks
tmpfile()doesn’t upload files, it creates temporary files in you system tmp folder.Without
sys_get_temp_dir()you could try and get the tmp dir with one of these:There are multiple examples of how to use them there and once you find it, see if its writable.
The only reason
tmpfile()returns false is if its not able to create the file. Similar issue here.