php8.5
Home/ Manual/ info / functions/ sys_get_temp_dir

sys_get_temp_dir

PHP function Edit on GitHub ✎

(PHP 5 >= 5.2.1, PHP 7, PHP 8)

Returns directory path used for temporary files

Description

sys_get_temp_dir(): string

Returns the path of the directory PHP stores temporary files in by default.

Parameters Parameters

Return Values

Returns the path of the temporary directory.

Examples

sys_get_temp_dir() example

php
<?php
// Create a temporary file in the temporary 
// files directory using sys_get_temp_dir()
$temp_file = tempnam(sys_get_temp_dir(), 'Tux');

echo $temp_file;
?>

The above example will output something similar to:

output
C:\Windows\Temp\TuxA318.tmp

See Also

Source: reference/info/functions/sys-get-temp-dir.xml · from the official PHP manual (php/doc-en)