获取包含文件信息的文件列表:
<?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);
?>
输出可能如下所示:
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"
}
ftp_rawlist() 函数返回包含文件信息的文件列表(来自 FTP 服务器上的指定目录)。
ftp_rawlist(
ftp_conn, dir, recursive);
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 |
返回值: | 一个数组,其中每个元素对应一行文本(不执行解析)。失败时返回 FALSE |
---|---|
PHP 版本: | 4+ |
PHP 变更日志: | 这个递归的PHP 4.3 中添加了参数 |
截取页面反馈部分,让我们更快修复内容!也可以直接跳过填写反馈内容!