function wp_tempnam($filename = '', $dir = '') {}

Returns a filename of a Temporary unique file.
Please note that the calling function must unlink() this itself.


  • string $filename: (optional) Filename to base the Unique file off
  • string $dir: (optional) Directory to store the file in

Return values

returns:a writable filename

Source code

function wp_tempnam($filename = '', $dir = '') {

	if ( empty($dir) )

		$dir = get_temp_dir();

	$filename = basename($filename);

	if ( empty($filename) )

		$filename = time();

	$filename = preg_replace('|\..*$|', '.tmp', $filename);

	$filename = $dir . wp_unique_filename($dir, $filename);


	return $filename;



No comments yet... Be the first to leave a reply!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: