Hàm ftp_rawlist () trong PHP
Thí dụ
Nhận danh sách các tệp với thông tin tệp:
<?php
// connect and login to FTP server
$ftp_server = "ftp.example.com";
$ftp_conn = ftp_connect($ftp_server) or die("Could not connect to $ftp_server");
$login = ftp_login($ftp_conn, $ftp_username, $ftp_userpass);
// get the file list for /
$filelist = ftp_rawlist($ftp_conn, "/");
// close connection
ftp_close($ftp_conn);
// output $filelist
var_dump($filelist);
?>
Đầu ra có thể trông giống như sau:
array(3)
{
[0] => string(57) "drw-rw-rw- 1 user group 0 Jan 03 08:33 images"
[1] => string(62) "-rw-rw-rw- 1 user group 160 Feb 16 13:54 php"
[2] => string(75) "-rw-rw-rw- 1 user group 20 Feb 14 12:22 test"
}
Định nghĩa và Cách sử dụng
Hàm ftp_rawlist () trả về danh sách các tệp với thông tin tệp (từ một thư mục được chỉ định trên máy chủ FTP).
Cú pháp
ftp_rawlist(ftp_conn, dir, recursive);
Giá trị tham số
Parameter | Description |
---|---|
ftp_conn | Required. Specifies the FTP connection to use |
dir | Required. Specifies the directory path. May include arguments for the LIST command. Tip: Use "." to specify the current directory |
recursive | Optional. By default, this function sends a "LIST" command to the server. However, if the recursive parameter is set to TRUE, it sends a "LIST -R" command |
Chi tiết kỹ thuật
Giá trị trả lại: | Một mảng trong đó mỗi phần tử tương ứng với một dòng văn bản (không thực hiện phân tích cú pháp). Trả về FALSE khi không thành công |
---|---|
Phiên bản PHP: | 4+ |
PHP Changelog: | Tham số đệ quy đã được thêm vào trong PHP 4.3 |
❮ Tham chiếu FTP PHP