Get the path to tmpfile ()

Poor quality ...

Is there a way to get the path to a file created using tmpfile() ?

Or do I need to do this myself using tempnam() ?

+48
php
Jun 26 2018-12-12T00:
source share
3 answers

It seems stream_get_meta_data () also works:

 $tmpHandle = tmpfile(); $metaDatas = stream_get_meta_data($tmpHandle); $tmpFilename = $metaDatas['uri']; fclose($tmpHandle); 
+80
Feb 20 '13 at 9:12
source share

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

+1
Jun 26 '12 at 17:17
source share

Like this

 $path = array_search('uri', @array_flip(stream_get_meta_data($GLOBALS[mt_rand()]=tmpfile()))); file_put_contents($path, 'hello'); 
0
Mar 14 '13 at 5:28
source share



All Articles