To get the underlying file path of a tmpfile file pointer: <?php $file = tmpfile(); $path = stream_get_meta_data($file)['uri']; // eg: /tmp/phpFx0513a