【发布时间】:2019-05-10 14:09:00
【问题描述】:
问题很简单,我尝试压缩文件的形式是下一个
$zipname = 'file.zip';
$zip = new ZipArchive;
$zip->open($zipname, ZipArchive::CREATE);
$zip->addFile(Excel::download(new SheetsExports($page1, $page2), $filename . '.xls'));
$zip->close()
echo 'Archive created!'
header('Content-disposition: attachment; filename=files.zip');
header('Content-type: application/zip');
<!-- end snippet -->
$zip->close()
echo 'Archive created!';
header('Content-disposition: attachment; filename=files.zip');
header('Content-type: application/zip');
在 laravel 控制器中,我使用外部库 Maatwebsite 然后当我执行 brwoser apair 时出现下一个错误
内容损坏错误
网站http://hall.test/indiceDeRotacion?_token=2Eh6WAl0W43l8ANzLz0e4GGW9reV04ESpURvEi1H&almacen=PRINCIPAL&fechaDesde=2018-05-01&fechaHasta=2019-04-30&proveedor=3000familia=&type=xls&compresion=on&email=&asunto=&submit=informe
所以我需要一个解决方案,或另一个外部库或我的代码中的正确方法
【问题讨论】:
-
“压缩”是什么意思?给定的代码会发生什么?
-
这是一个 ZIP 文件
-
那么,如果该代码的结果是一个 ZIP 文件,那有什么问题呢?
-
好吧,我在尝试使用 laravel 项目中的 maatwebsite 插件获取 Excel 压缩文件时遇到问题
-
这可能是您在此处发布它的原因 - 但这个问题究竟是什么?有没有给出任何错误信息?运行代码时会发生什么?这与您期望此代码执行的操作有何不同?
标签: php laravel laravel-5 maatwebsite-excel