• PHP Video Tutorials

PHP - Function tempnam()



The tempnam() function can create a temporary file with a unique filename in the specified directory, and it can return new temporary filename (with path), or false on failure.

Syntax

string tempnam ( string $dir, string $prefix )

This function can create a file with a unique filename, with access permission set to 0600 in the specified directory. If a directory doesn't exist or not writable, the tempnam() function may generate a file in the system's temporary directory and return the full path to that file includes its name.

Example

<?php 
   echo tempnam("C:\PhpProject", "TMP0");
?>

Output

C:\PhpProject\TMPABFA.tmp
 
php_function_reference.htm
Advertisements