The following line in my code is returning an empty array when in fact the given path is not empty:
$file_list = @ftp_nlist( $link, '-a ' . $path );
The permission on the path is 775. When I ls
the path in my OS shell, I see the expected list of files.
So why isn't ftp_nlist
seeing them?
Most likely because the FTP server does not understand the -a
. It tries to interpret it as a path or a file mask. It matches no file, hence the empty result set.
Try to remove the switch.
Note that while some servers do support the -a
, or are at least able to ignore it, it violates the FTP specification. There are no switches at all in NLST
command (or any other FTP command).