目前我有一个脚本可以做这种事情:
//Connect to the FTP server
$conn_id = connect_to_server($server, $user, $password);
//Switch to the directory with the files
ftp_chdir($conn_id, $directory);
//Get the contents of the current directory then iterate over them
$contents = ftp_nlist($conn_id, ".");
//loop through files and download them
foreach($contents as $file) {
ftp_get($conn_id, $local_filename, $file, FTP_BINARY);
}
问题是ftp_get
气球失控,内存不足。我找到的唯一解决方案是在每次连接之前关闭ftp_get
连接。
有没有办法在ftp_get
不关闭连接的情况下释放内存?