各位開發(fā)人員,我想下載多個文件作為一個 zip,但我不斷收到錯誤下面是我試過的代碼 public function multiple($id){$files = documents::where('claim_id', $id)->get(); if ($files != '') { $filepath = storage_path('app/Documents/'); foreach($files as $file) { $zipper = new \Chumper\Zipper\Zipper; $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(); }} 附件是我得到的錯誤
1 回答

慕村9548890
TA貢獻1884條經(jīng)驗 獲得超4個贊
看起來您沒有向 Zip 添加任何文件。
我認為:
$zipper->make($filepath.'doc.zip');
應該:
$zipper->make($filepath.'doc.zip')->add($fi)->close();
確保文件和 zip 位于storage
文件夾中。
- 1 回答
- 0 關注
- 169 瀏覽
添加回答
舉報
0/150
提交
取消