我从URL抓取zip文件,然后我将zip文件复制到磁盘上以从磁盘中取出并提取它。我想消除必须将zip写入磁盘以优化它的步骤。这是我的代码......
$url_zip = 'http://returns_my_zip_file';
$new_file = '/zip_name.zip';
if (!copy($url_zip, $new_file)) { //<--- I want to eliminate this step.
echo "\n\nFailed to copy file...\n\n";
}
$zip = new ZipArchive;
if(is_readable($new_file)) {
$zip = new ZipArchive;
if ($zip->open($new_file) === TRUE) {
$zip->extractTo('ExtractToThisFolder');
$zip->close();
echo 'ok';
} else {
echo 'failed';
}
}
提前致谢。