note 111721 deleted from function.tmpfile by aharvey
| From: | aharvey@php.net | Date: | Wed, 20 Mar 2013 18:52:24 +0000 |
| Subject: | note 111721 deleted from function.tmpfile by aharvey | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-194150@lists.php.net to get a copy of this message | ||
Note Submitter: Anonymous
----
If you simply need a random filename in the tmp directory (so it will be auto-removed later by the
system), you can do this.
<?php
$tmpDest = tempnam(sys_get_temp_dir(), 'prefix') . '.txt';
file_put_contents($tmpDest, 'some text');
?>
It will be a file name, not a file handle, so you don't have to worry about closing it.