PHP:从FileZilla服务器获取文件

PHP:从FileZilla服务器获取文件,php,server,ftp,connect,filezilla,Php,Server,Ftp,Connect,Filezilla,我想连接到另一个服务器感谢PHP。 我的PHP代码是: // FTP server details $ftpHost = 'server4.streamserver24.com'; $ftpUsername = ''; $ftpPassword = '*****'; // open an FTP connection $connId = ftp_connect($ftpHost) or die("Couldn't connect to $ftpHost"); // login to FT

我想连接到另一个服务器感谢PHP。 我的PHP代码是:

// FTP server details
$ftpHost   = 'server4.streamserver24.com';
$ftpUsername = '';
$ftpPassword = '*****';

// open an FTP connection
$connId = ftp_connect($ftpHost) or die("Couldn't connect to $ftpHost");

// login to FTP server
$ftpLogin = ftp_login($connId, $ftpUsername, $ftpPassword);
连接后,我想从该服务器的文件夹名“mp3”中获取文件。我所尝试的:

$sDir = 'mp3/';
$rDir = opendir($sDir);

它显示一个白色站点:/try print\r($contents);看看你有没有得到任何信息。它再次显示空页。可能是因为路径。您可以尝试绝对路径(/path/to/mp3或c:\path\to\mp3)或尝试当前文件夹以查看它的起始目录:$contents=ftp\u mlsd($connId,“.”);请注意,对于
ftp\u mlsd
,您需要PHP7.2,这也是问题所在。等等您将如何使用FTP客户端手动执行此操作?检查PHP API中是否有与mget类似的内容,因此请确保阅读API文档。
// FTP server details
$ftpHost   = 'server4.streamserver24.com';
$ftpUsername = '';
$ftpPassword = '*****';

// open an FTP connection
$connId = ftp_connect($ftpHost) or die("Couldn't connect to $ftpHost");

// login to FTP server
$ftpLogin = ftp_login($connId, $ftpUsername, $ftpPassword);

// get contents of the directory mp3
$contents = ftp_mlsd($connId , "mp3");

foreach($contents as $file_or_directory){
    if($file_or_directory['type'] == 'file'){ // only files
          print_r($file_or_directory);
    }
}