Zip google cloude存储文件损坏

时间:2016-02-25 16:53:07

标签: php google-cloud-storage ziparchive

我使用以下代码压缩google文件,并且zip文件创建成功,但双击后显示错误消息作为屏幕截图。我该如何解决?

        $zip = new ZipArchive();
        $zipname = time() . ".zip"; // Zip name
        $zip->open($zipname, ZipArchive::CREATE);

        $files = array('http://lh3.googleusercontent.com/k8tmo5m0KZLJbZjLiSMHjefsjJXfQSS_r6julCj8LCW-OsOFf715YOlWvHE9Xze4Rm2gxsWhl9OCLLHsXyluyDFz4n1xRQHOijS3iOs',
            'http://lh3.googleusercontent.com/hk_y_5BKSCJpNOqpCkq7mWTPzljo8kXmLf2qQR16K6HASfEeDu0yxNBcheFyjnFUCMOl6-fZiJlp4n4Kb_fhihUGyn58TUDRD1iECrur');

        foreach ($files as $file) {
            $zip->addFromString(basename($file), file_get_contents($file));
        }

        $zip->close();

        header('Content-Type: application/zip');
        header('Content-disposition: attachment; filename=' . $zipname);
        header('Content-Length: ' . filesize($zipname));
        readfile($zipname);

enter image description here

0 个答案:

没有答案