PHP ftp_nlist () function
Definition and Usage
ftp_nlist () a list of files in a directory on the FTP server function returns.
If successful, the array of files in the specified directory of the composition is returned. If it fails, it returns FALSE.
grammar
ftp_nlist(ftp_connection,dir)
参数 | 描述 |
---|---|
ftp_connection | 必需。规定要使用的 FTP 连接。 |
dir | 必需。规定要检查的目录。请使用 "." 来获得当前目录。 |
Tips and Notes
Note: This function is not available for IIS (Internet Information Server).It returns nothing.
Examples
<?php
$conn = ftp_connect("ftp.testftp.com") or die("Could not connect");
ftp_login($conn,"admin","ert456");
print_r(ftp_nlist($conn,"images"));
ftp_close($conn);
?>
$conn = ftp_connect("ftp.testftp.com") or die("Could not connect");
ftp_login($conn,"admin","ert456");
print_r(ftp_nlist($conn,"images"));
ftp_close($conn);
?>
The code above will output:
array(3)
{
[0]=> "flower.gif"
[1]=> "car.gif"
[2]=> "house.gif"
}
{
[0]=> "flower.gif"
[1]=> "car.gif"
[2]=> "house.gif"
}
Complete PHP FTP Reference