'ftp_nlist returns false on file
As the title says, ftp-nlist returns false on files. On directories, it works fine...
First my code:
<?php
$ftp_server = "ftp.myserver.com";
$ftp_user_name = "myusername";
$ftp_user_pass = "mypassword";
$ftp = ftp_connect($ftp_server);
$login_result = ftp_login($ftp, $ftp_user_name, $ftp_user_pass);
// check connection
if ((!$ftp) || (!$login_result)) {
echo "FTP connection has failed!\n";
exit;
} else {
echo "Connected.\n";
}
ftp_pasv( $ftp, true );
$list = ftp_nlist( $ftp, '/' );
if( empty( $list ) ) {
echo "File list is empty.\n";
} else {
foreach( $list as $file ) {
echo "$file\n";
}
$list = ftp_nlist( $ftp, '/ftptest.php' );
if( ! $list ) {
echo "\nNot found.\n";
} else {
echo "\nFound!\n";
}
}
// close the FTP connection
ftp_close($ftp);
?>
As you can see, I already set passive mode. The output is:
Connected.
/.
/..
/htdocs
/cgi-bin
/logs
/ftptest.php
Not found.
ftptest.php is a file (and actually the php script I'm executing, but it fails on any file).
This behavior started immediately after I upgraded from Debian 10 (Buster) to Debian 11 (Bullseye). What could be causing this?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
