function drupal_tempnam


Error message

User warning: The following module is missing from the file system: theme/theme. For information about how to fix this, see the documentation page. in _drupal_trigger_error_with_delayed_logging() (line 1156 of /var/www/html/elmsln_community/
cis7 drupal_tempnam($directory, $prefix)
cle7 drupal_tempnam($directory, $prefix)
elmsmedia7 drupal_tempnam($directory, $prefix)
icor7 drupal_tempnam($directory, $prefix)
meedjum_blog7 drupal_tempnam($directory, $prefix)
mooc7 drupal_tempnam($directory, $prefix)

Creates a file with a unique filename in the specified directory.

PHP's tempnam() does not return a URI like we want. This function will return a URI if given a URI, or it will return a filepath if given a filepath.

Compatibility: normal paths and stream wrappers.


$directory: The directory where the temporary filename will be created.

$prefix: The prefix of the generated temporary filename. Note: Windows uses only the first three characters of prefix.

Return value

The new temporary filename, or FALSE on failure.

See also


Related topics

21 calls to drupal_tempnam()
advagg_save_data in sites/all/modules/ulmus/advagg/
Save data to a file.
backup_file::temporary_file in sites/all/modules/ulmus/backup_migrate/includes/
Get a temporary file name with path.
BaconmockupProvider::generateImage in sites/all/modules/ulmus/devel_image_provider/plugins/devel_image_provider/provider/BaconmockupProvider.class.php
Image generation handler.
boost_write_file in sites/all/modules/ulmus/boost/boost.module
Write to a file. Ensures write is atomic via rename operation.
ctools_stylizer_image_processor::command_slice in sites/all/modules/ulmus/ctools/includes/
Take a slice out of the current workspace and save it as an image.

... See full list


includes/, line 2424
API for handling file uploads and server file management.


function drupal_tempnam($directory, $prefix) {
  $scheme = file_uri_scheme($directory);

  if ($scheme && file_stream_wrapper_valid_scheme($scheme)) {
    $wrapper = file_stream_wrapper_get_instance_by_scheme($scheme);

    if ($filename = tempnam($wrapper->getDirectoryPath(), $prefix)) {
      return $scheme . '://' . drupal_basename($filename);
    else {
      return FALSE;
  else {
    // Handle as a normal tempnam() call.
    return tempnam($directory, $prefix);



Error message

  • Warning: Cannot modify header information - headers already sent by (output started at /var/www/html/elmsln_community/ in drupal_send_headers() (line 1499 of /var/www/html/elmsln_community/
  • Error: Call to undefined function apc_delete() in DrupalAPCCache->clear() (line 289 of /var/www/html/elmsln_community/
The website encountered an unexpected error. Please try again later.