PHP ftp_rawlist() function
Definition and Usage
The ftp_rawlist() function returns a detailed list of files in the specified directory.
Syntax
ftp_rawlist(ftp_connection,dir,recursive)
Parameter | Description |
---|---|
ftp_connection | Required. Specifies the FTP connection to use (identifier for the FTP connection). |
dir | Required. Specifies the directory. Use "." to specify the current directory. |
recursive | Optional. By default, the function sends the "LIST" command to the server. If the recursive parameter is set to true, the "LIST -R" command is sent. |
说明
ftp_rawlist() 函数将执行 FTP LIST 命令,并把结果返回为一个数组。数组的每个元素为返回文本的每一行,输出结构不会被解析。
使用函数 ftp_systype() 可以用来判断 FTP 服务器的类型,从而可以用来判断返回列表的类型。
实例
<?php $conn = ftp_connect("ftp.testftp.com") or die("Could not connect"); ftp_login($conn,"admin","ert456"); print_r (ftp_rawlist($conn,".")); ftp_close($conn); ?>
输出类似:
Array ( [0] => dr--r--r-- 1 user group 0 Feb 15 13:02 . [1] => dr--r--r-- 1 user group 0 Feb 15 13:02 .. [2] => drw-rw-rw- 1 user group 0 Jan 03 08:33 images [3] => -rw-rw-rw- 1 user group 160 Feb 16 13:54 test.php [4] => -rw-rw-rw- 1 user group 20 Feb 14 12:22 test.txt )