PHP tempnam() Function

The tempnam() function creates a temporary file with a unique filename in the specified directory.Returns the new temporary filename (with path), or FALSE on failure.

string tempnam ( string $dir , string $prefix )

Creates a file with a unique filename, with access permission set to 0600, in the specified directory. If the directory does not exist or is not writable, tempnam() may generate a file in the system's temporary directory, and return the full path to that file, including its name.

Example -

ParameterDescription
dirThe directory where the temporary filename will be created
prefixThe prefix of the generated temporary filename

Note -

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