Codex tools: Log in
This function can be used before saving a file to make sure it has a filename that is sanitized and unique for the given directory.
If the filename is not unique, then a number will be added to the filename before the extension, and will continue adding numbers until the filename is unique.
The callback is passed three parameters:
Note: ( In the WordPress code comments the third parameter is described as being the file extension. Looking at the function itself, this is not true. )
$newfilename = wp_unique_filename( $path_being_saved_to, $filename_to_check );
wp_unique_filename() is located in wp-includes/functions.php.