W3Schools.com

PHP tempnam() Function


PHP Filesystem Reference 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


PHP Filesystem Reference Complete PHP Filesystem Reference
WEB HOSTING
Best Web Hosting
PHP MySQL Hosting
Best Hosting Coupons
UK Reseller Hosting
Cloud Hosting
Top Web Hosting
$7.95/mo SEO Hosting
Premium Website Design
WEB BUILDING
XML Editor - Free Trial!
FREE Website BUILDER
Free Website Templates Free CSS Templates
Make Your Own Website
W3SCHOOLS EXAMS
Get Certified in:
HTML, CSS, JavaScript, XML, PHP, and ASP
W3SCHOOLS BOOKS
New Books:
HTML, CSS
JavaScript, and Ajax
STATISTICS
Browser Statistics
Browser OS
Browser Display
SHARE THIS PAGE