function FileSystemInterface::tempnam

Same name in other branches
  1. 8.9.x core/lib/Drupal/Core/File/FileSystemInterface.php \Drupal\Core\File\FileSystemInterface::tempnam()
  2. 10 core/lib/Drupal/Core/File/FileSystemInterface.php \Drupal\Core\File\FileSystemInterface::tempnam()
  3. 11.x core/lib/Drupal/Core/File/FileSystemInterface.php \Drupal\Core\File\FileSystemInterface::tempnam()

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.

Parameters

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

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

Return value

string|bool The new temporary filename, or FALSE on failure.

See also

tempnam()

https://www.drupal.org/node/515192

Related topics

1 method overrides FileSystemInterface::tempnam()
FileSystem::tempnam in core/lib/Drupal/Core/File/FileSystem.php
Creates a file with a unique filename in the specified directory.

File

core/lib/Drupal/Core/File/FileSystemInterface.php, line 246

Class

FileSystemInterface
Provides an interface for helpers that operate on files and stream wrappers.

Namespace

Drupal\Core\File

Code

public function tempnam($directory, $prefix);

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.