目前我有一个脚本可以执行此类操作:
//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
内存?