I'm experiencing the same problem as here: http://stackoverflow.com/questions/1609140/ftp-nlist-command-not-working
where php ftp_nlist just returns false.
In put in the command ftp_nlist ($conn_id, true)
But then, the script just runs until it timesout with the following error:
Warning: ftp_nlist() [function.ftp-nlist]: php_connect_nonb() failed: Operation now in progress (115) in /var/www/vhosts/site.com/httpdocs/sftp.php on line 18 bool(false)
Any ideas?? if I don't set pasv mode, then it just returns false.
Something that the ftp server said was that they passive ports are: 10860-10864
I'm not sure if that's something I need to do or set when connecting to the server?
Code is:
<?php
ini_set("display_errors", 1);
error_reporting(E_ALL);
$conn_id = ftp_ssl_connect('site.com', '10021');
$login_result = ftp_login($conn_id, "user", 'pass');
ftp_pasv( $conn_id, true );
// check connection
if ((!$conn_id) || (!$login_result)) {
echo "FTP connection has failed!";
exit;
}
// turn passive mode on
//ftp_pasv($conn_id, true);
echo "Connected";
//secho ftp_pwd($conn_id);
$contents = ftp_nlist($conn_id, ".");
var_dump($contents);
ftp_close($conn_id);
?>
Thanks so much!
Edit: When I connect with lftp to the server, I noticed that there is this message:
<--- 200 PROT P OK, data channel will be secured. ---> PASV <--- 227 Entering Passive Mode (192,168,1,171,42,108) ---- Address returned by PASV seemed to be incorrect and has been fixed ---- Connecting data socket to (209.154.100.57) port 10860 ---- Data connection established ---> LIST
What is that about the address being returned wrong?
Could that be that problem with PHP?