hy developers, i want to download multiple files as a zip, but i keep getting errors
below is the code i have tried
public function multiple($id){ $files = documents::where('claim_id', $id)->get(); if ($files != '') { $filepath = storage_path('app/Documents/'); foreach($files as $file) { $zipper = new ChumperZipperZipper; $fi = storage_path('app/Documents/'.$file->file_name); $zipper->make($filepath.'doc.zip'); } return response()->download($filepath.'doc.zip'); } else{ Alert::info('Info', 'No Documents Available'); return redirect()->back(); } }
attached is the error i get
Advertisement
Answer
Looks like you didn’t add any files to your Zip.
I think:
$zipper->make($filepath.'doc.zip');
Should be:
$zipper->make($filepath.'doc.zip')->add($fi)->close();
Make sure the files and zip are in the storage
folder.