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);
?>
ftp_pasv() can only be called after a successful login. Otherwise will fail (ie return false).
Move it to after your login call.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.