the problem very easy the form that i try to compress a file is the next
$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');
in a laravel controller , i use the external library Maatwebsite then when i execute the brwoser apair the next error
Corrupted Content Error
The site at http://hall.test/indiceDeRotacion?_token=2Eh6WAl0W43l8ANzLz0e4GGW9reV04ESpURvEi1H&almacen=PRINCIPAL&fechaDesde=2018-05-01&fechaHasta=2019-04-30&proveedor=3000 familia=&type=xls&compresion=on&email=&asunto=&submit=informe
so i need a solution , or another external library or the correct way in my code for it works
i fix the issue with this code
$zip = new ZipArchive;
if ($zip->open('yyyy.zip', ZipArchive::CREATE) === true) {
$zip->addFile(Excel::download(new SheetsExports($page1, $page2), $filename . '.xls')->getFile(),
'xxxx.xls');
$zip->close();
}
return response()->download("yyyy.zip");