Hướng dẫn php temp upload directory - thư mục tải lên tạm thời php

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

SYS_GET_TEMP_DIR - Trả về đường dẫn thư mục được sử dụng cho các tệp tạm thờiReturns directory path used for temporary files

Sự mô tả

sys_get_temp_dir (): chuỗi(): string

Thông số

Chức năng này không có tham số.

Trả về giá trị

Trả về đường dẫn của thư mục tạm thời.

Ví dụ

Ví dụ #1 sys_get_temp_dir () ví dụsys_get_temp_dir() example

// 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;
?>

Ví dụ trên sẽ xuất ra một cái gì đó tương tự như:

C:\Windows\Temp\TuxA318.tmp

Xem thêm

  • tmpfile () - tạo một tệp tạm thời
  • Tempnam () - Tạo tệp có tên tệp duy nhất

Osakawebbie ¶

5 năm trước

If running on a Linux system where systemd has PrivateTmp=true (which is the default on CentOS 7 and perhaps other newer distros), this function will simply return "/tmp", not the true, much longer, somewhat dynamic path.

Royanee tại Yahoo Dot Com ¶

8 năm trước

As of PHP 5.5.0, you can set the sys_temp_dir INI setting so that this function will return a useful value when the default temporary directory is not an option.

Ẩn danh ¶

14 năm trước

This function does not always add trailing slash. This behaviour is inconsistent across systems, so you have keep an eye on it.

Ẩn danh ¶

14 năm trước

it should be mentioned that the return value of sys_get_temp_dir() can be set using the ini-directive 'sys_temp_dir' globally as well as per directory by using
php_admin_value sys_temp_dir /path/to/tmp

7 năm trước

14 năm trước

A very helpful thing to note when on Linux:

If you are running PHP from the commandline you can use the environment variable: TMPDIR - to change the location without touching php.ini. - This should work on most versions of PHP.

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

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

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

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

7 năm trước

Nimja ¶

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

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

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

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

Bert-Jan tại Bugbyte Dot NL ¶

12 năm trước

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

OHCC tại 163 dot com ¶

6 năm trước

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

echo0

echo1

echo2

echo3

echo4

echo5

echo6

echo7

echo8

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

Ẩn danh ¶

14 năm trước

$temp_file;
?>
0