douchuanhan8384 2018-08-24 14:48
浏览 149

PHP ZipArchive - 只有doc文件损坏

I am successfully creating a zip archive. However, when I unzip then try to view the files in the unzipped archive on my desktop, only .doc files are corrupt. PDF, HTML, CSV, etc. all open fine.

Any ideas as to why only .doc files are being corrupted? This uses cakephp

The function:

$zip = new \ZipArchive();
            $time = Time::now();
            $t2 = $time->i18nFormat('yyyyMMddHHmmss');
            $zipfilename = 'file' . $t2 . '.zip';
            $zip->open('[path]' . $zipfilename, \ZipArchive::CREATE | \ZipArchive::OVERWRITE);
            foreach($formData['docType'] as $doc) {
                $file = $this->getFile($doc,$formData['id']);
                $filepath = explode('/', $file);
                $filename = end($filepath);
                $zip->addFile($file, $filename);
            }
            $zip->close();

            header('Content-type: application/zip');
            header('Content-disposition: attachment; filename=' . $zipfilename);
            ob_clean();
            flush();
            readfile('[path]' . $zipfilename);
            exit();
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 关于#c语言#的问题:我现在在做一个墨水屏设计,2.9英寸的小屏怎么换4.2英寸大屏
    • ¥15 模糊pid与pid仿真结果几乎一样
    • ¥15 java的GUI的运用
    • ¥15 Web.config连不上数据库
    • ¥15 我想付费需要AKM公司DSP开发资料及相关开发。
    • ¥15 怎么配置广告联盟瀑布流
    • ¥15 Rstudio 保存代码闪退
    • ¥20 win系统的PYQT程序生成的数据如何放入云服务器阿里云window版?
    • ¥50 invest生境质量模块
    • ¥15 nhanes加权logistic回归,svyglm函数