Same name and namespace in other branches
- 4.7.x includes/file.inc \file_directory_temp()
- 5.x includes/file.inc \file_directory_temp()
- 7.x includes/file.inc \file_directory_temp()
- 8.9.x core/includes/file.inc \file_directory_temp()
Determine the default temporary directory.
Return value
A string containing a temp directory.
Related topics
6 calls to file_directory_temp()
- file_save_data in includes/
file.inc - Save a string to the specified destination.
- file_save_upload in includes/
file.inc - Saves a file upload to a new location.
- install_main in ./
install.php - The Drupal installation happens in a series of steps. We begin by verifying that the current environment meets our minimum requirements. We then go on to verify that settings.php is properly configured. From there we connect to the configured database…
- system_file_system_settings in modules/
system/ system.admin.inc - Form builder; Configure the site file handling.
- system_requirements in modules/
system/ system.install - Implementation of hook_requirements().
File
- includes/
file.inc, line 1112 - API for handling file uploads and server file management.
Code
function file_directory_temp() {
$temporary_directory = variable_get('file_directory_temp', NULL);
if (is_null($temporary_directory)) {
$directories = array();
// Has PHP been set with an upload_tmp_dir?
if (ini_get('upload_tmp_dir')) {
$directories[] = ini_get('upload_tmp_dir');
}
// Operating system specific dirs.
if (substr(PHP_OS, 0, 3) == 'WIN') {
$directories[] = 'c:\\windows\\temp';
$directories[] = 'c:\\winnt\\temp';
$path_delimiter = '\\';
}
else {
$directories[] = '/tmp';
$path_delimiter = '/';
}
foreach ($directories as $directory) {
if (!$temporary_directory && is_dir($directory)) {
$temporary_directory = $directory;
}
}
// if a directory has been found, use it, otherwise default to 'files/tmp' or 'files\\tmp';
$temporary_directory = $temporary_directory ? $temporary_directory : file_directory_path() . $path_delimiter . 'tmp';
variable_set('file_directory_temp', $temporary_directory);
}
return $temporary_directory;
}