The ftp_nlist() function returns a list of files in the specified directory on the FTP server.
Syntax
ftp_nlist(con,dir);
Parameters
con − The FTP connection
dir − The directory to be listed
Return
The ftp_nlist() function returns an array of file names on success or FALSE on failure.
Example
The following is an example wherein we are getting the list of files in the current directory −
<?php $ftp_server = "192.168.0.4"; $ftp_user = "tim"; $ftp_pass = "wthbn#@121"; $con = ftp_connect($ftp_server) or die("Could not connect to $ftp_server"); $login = ftp_login($con, $ftp_user, $ftp_pass); $list = ftp_nlist($con, "."); var_dump($list); // close ftp_close($con); ?>