2
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?

3 Answers 3

1

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/

Sign up to request clarification or add additional context in comments.

3 Comments

I don't quite get what you mean. I am able to access and browse it perfectly fine using a desktop FTP client, just need to replicate this using PHP so I can grab what's in the contents of one of the sub directories.
So you log in to the same server with the same user and are able to browse to this directory? Ok. Ill update the answer.
I've added the full code that is producing it now. It's weird '/2689312/' and '' produce the same thing. But when I log into the FTP using a client, the default directory is /2689312
1

You must first use ftp_chdir to change the directory.

It took me forever to figure this one out.

Comments

0

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

3 Comments

With that var_dump(ftp_nlist($connect, './outgoing')); var_dump(ftp_nlist($connect, '/outgoing/')); var_dump(ftp_nlist($connect, '/2689312/')); var_dump(ftp_nlist($connect, './2689312/outgoing/')); I now get bool(false) bool(false) array(1) { [0]=> string(8) "outgoing" } bool(false)
I believe you are in the wrong working directory. What are the outputs from: var_dump(ftp_pwd($connect)); var_dump(ftp_rawlist($connect, '.')); var_dump(ftp_rawlist($connect, '/2689312/'));
string(8) "/2689312" array(1) { [0]=> string(63) "drwxrwxrwx 1 owner group 0 May 09 08:16 outgoing" } array(1) { [0]=> string(63) "drwxrwxrwx 1 owner group 0 May 09 08:16 outgoing" }

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.