由于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);
答案 0 :(得分:0)
// 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);
}
}