PHP ftp_nlist() Function
Definition and Usage
ftp_nlist() function returns the file list of the specified directory.
If successful, it returns an array of filenames under the given directory, otherwise it returns false.
Syntax
ftp_nlist(ftp_connection,dir)
Parameter | Description |
---|---|
ftp_connection | Required. Specifies the FTP connection to be used (the identifier of the FTP connection). |
dir | Required. Specifies the directory to be checked. Use "." to get the current directory. |
Tips and Comments
Note:This function is not applicable to IIS (Internet Information Server). It returns nothing.
Example
<?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); ?>
Output similar to:
array(3) { [0]=> "flower.gif" [1]=> "car.gif" [2]=> "house.gif" }