Why is ftp_nlist returning an empty array for a no

2019-06-13 19:43发布

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?

标签: php ftp
1条回答
看我几分像从前
2楼-- · 2019-06-13 20:15

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

查看更多
登录 后发表回答