Latest web development tutorials
 

PHP tempnam() Function


< Complete PHP Filesystem Reference

Definition and Usage

The tempnam() function creates a temporary file with a unique filename in the specified directory.

This function returns the new temporary filename, or FALSE on failure.

Syntax

tempnam(dir,prefix)

Parameter Description
dir Required. Specifies the directory of where to create the temp file
prefix Required. Specifies the start of the filename

Tips and Notes

Note: If the specified directory does not exist, tempnam() may generate a file in the system's temporary directory.

Tip: See also tmpfile()


Example

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

The output of the code above could be:

C:\inetpub\testweb\TMP1.tmp

< Complete PHP Filesystem Reference