Poor quality ...
Is there a way to get the path to a file created using tmpfile() ?
tmpfile()
Or do I need to do this myself using tempnam() ?
tempnam()
It seems stream_get_meta_data () also works:
$tmpHandle = tmpfile(); $metaDatas = stream_get_meta_data($tmpHandle); $tmpFilename = $metaDatas['uri']; fclose($tmpHandle);
sys_get_temp_dir()
Will return the current configuration directory for storing tmp files.
Regarding the generated file name, you should use tempnam() to use the path to the file with the name that you / the user defined.
http://www.php.net/manual/en/function.sys-get-temp-dir.php
Like this
$path = array_search('uri', @array_flip(stream_get_meta_data($GLOBALS[mt_rand()]=tmpfile()))); file_put_contents($path, 'hello');