I have MAMP so I did a little testing using the first example in the php manual page for ftp_nlist
, and was getting the same error as you (bool(false)
). Turns out, if using that code:
// set up basic connection
$conn_id = ftp_connect($ftp_server);
// login with username and password
$login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);
// get contents of the current directory
$contents = ftp_nlist($conn_id, ".");
// output $contents
var_dump($contents);
and the login fails either because of a bad username or password, if will fail with the bool(false)
message.
Better to do something that will give you better info as to where it failed (if it does fail):
// set up basic connection variables
$ftp_server='127.0.0.1';
$ftp_user_name='user';
$ftp_user_pass='pass';
//initiate connection
$conn_id = ftp_connect($ftp_server);
// login with username and password
$login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass) or die ('login failed');
// get contents of the current directory
$contents = ftp_nlist($conn_id, ".") or die ('could not get contents');
// output $contents
var_dump($contents);
I tested this and it works. Given the right credentials, it will log in and dump the dir. If the credentials are bad, it will die
with a 'login failed' message. If the path is bad, it will die
with a 'could not get contents' message; so at least if it does break down you'll have a better idea of where.
HTH