Quickie...
Is there a way to retrieve the path of a file created by tmpfile()
?
Or do I need to do it myself with tempnam()
?
php stores all temporary files, that includes uploaded files, in the temporary files directory as specified in the php. ini. Note that for uploads, those files might be removed as soon as the script the file was uploaded to was terminated (so unless you delay that script, you probably won't see the uploaded file).
The tmpfile() function in PHP is an inbuilt function which is used to create a temporary file with a unique name in read-write (w+) mode. The file created using tmpfile() function gets automatically deleted when close using fclose() or when there are no remaining references to the file handle.
Returned value If successful, tmpfile() returns a pointer to the stream associated with the file created. If tmpfile() cannot open the file, it returns a NULL pointer. On normal termination (exit()), these temporary files are removed.
It seems stream_get_meta_data() also works :
$tmpHandle = tmpfile(); $metaDatas = stream_get_meta_data($tmpHandle); $tmpFilename = $metaDatas['uri']; fclose($tmpHandle);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With