Why is ftp_nlist returning an empty array for a no

2019-06-13 19:50发布

问题:

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?

回答1:

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).



标签: php ftp