PHP FTP directory listing error

2019-07-09 07:42发布

array(1) {
  [0]=>
  string(8) "outgoing"
}
bool(false)
array(1) {
  [0]=>
  string(8) "outgoing"
}
bool(false)

Is currently being produced by

$connect    = ftp_connect('example.com');
$result     = ftp_login($connect, 'username', 'password');

echo '<pre>';
var_dump(ftp_nlist($connect, ''));
var_dump(ftp_nlist($connect, '/outgoing/'));
var_dump(ftp_nlist($connect, '/2689312/'));
var_dump(ftp_nlist($connect, '/2689312/outgoing/'));

But why isn't it letting me list lower than the top directory? This is really stumping me. I can't even get into a sub folder let alone the full folder scheme I need to open.

Any ideas?

标签: php ftp
3条回答
疯言疯语
2楼-- · 2019-07-09 08:15

To get the list of the CWD, instead of:

var_dump(ftp_nlist($connect, ''));

you need to do:

var_dump(ftp_nlist($connect, '.'));

I believe if you want to deeper from there the directory must be:

./subdirectory

查看更多
smile是对你的礼貌
3楼-- · 2019-07-09 08:21

You must first use ftp_chdir to change the directory.

It took me forever to figure this one out.

查看更多
等我变得足够好
4楼-- · 2019-07-09 08:26

Most FTP services do not let the FTP client who is connecting go further down than the home directory. So check the home directory of the user that is connecting.

It could also be that you are calling the directory wrong.

If /2689312/ is below your starting directory. Try doing ../2689312/

查看更多
登录 后发表回答