tempnam
Create a file with a unique file name
tempnam()
function creates a temporary file with a unique file name.
If successful, the function returns the new temporary file name. If it fails, return false.
<?php echo tempnam ( "C:\inetpub\testweb" , "TMP0" ) ; ?>
Output:
C:\inetpub\testweb\TMP1.tmp
tempnam ( dir , prefix )
parameter | describe |
---|---|
dir | Required. Specifies the directory where temporary files are created. |
prefix | Required. Specify the beginning of the file name. |
Create a file with a unique file name in the specified directory. If the directory does not exist, tempnam()
will generate a file in the system temporary directory and return its file name.
Prior to PHP 4.0.6, the behavior of tempnam()
function depends on the system. In Windows, the TMP environment variable will pass the dir parameter, in Linux, the TMPDIR environment variable will take precedence, while in SVR4, the dir parameter is always used if the directory it points to exist.