file_create_filename($basename, $directory)
Creates a full file path from a directory and filename.
If a file with the specified name already exists, an alternative will be used.
Parameters
$basename: String filename
$directory: String containing the directory or parent URI.
Return value
File path consisting of $directory and a unique filename based off of $basename.
Related topics
File interface Common file handling functions.
File
core/includes/file.inc, line 759 API for handling file upl