Reputation: 21
I have a problem with the PHP code shown below: I am able to connect to and login on the right FTP server. But when I try to get a list of the content of the main directory using ftp_rawlist, I always get: bool(false), even when in passive mode.
Does somebody see the problem here.
<?
// Inloggegevens
$ftp_server = "***";
$ftp_user = "***";
$ftp_pass = "***";
// Verbinding maken in passive mode
$conn = ftp_connect($ftp_server, 2121) or die("Couldn't connect to $ftp_server");
ftp_pasv($conn, true);
// Inloggen mislukt
if (!@ftp_login($conn, $ftp_user, $ftp_pass)) {
echo "Couldn't login on server.";
exit;
}
// Inloggen gelukt
$list = ftp_rawlist($conn, '/');
var_dump($list);
// Verbinding sluiten
ftp_close($conn);
?>
Upvotes: 2
Views: 3572
Reputation: 932
ftp_pasv() can only be called after a successful login. Otherwise will fail (i.e. return false).
Move it to after your login call.
Upvotes: 4