我正在尝试下载zip生成的文件,但我收到FileNotFoundException
,这是代码:
$zipper = new \Chumper\Zipper\Zipper;
foreach($request->values as $id_post){
$post = Post::find($id_post);
$imagenes[] = public_path().'/uploads/posts/'.$post->imagen;
}
$nombreZip = 'test'.time().'.zip';
$rutaZip = (public_path().'/zips/'.$nombreZip);
$zipper->make($rutaZip)->add($imagenes);
return (response()->download($rutaZip, 'posts.zip'));
我已经检查了返回的文件路由,文件就在那里,具有相同的名称和所有内容。有任何想法吗?
答案 0 :(得分:0)
试试这个:
$zipper = new \Chumper\Zipper\Zipper;
foreach($request->values as $id_post){
$post = Post::find($id_post);
$imagenes[] = 'public/uploads/posts/'.$post->imagen;
}
$nombreZip = 'test'.time().'.zip';
$rutaZip = (public_path().'/zips/'.$nombreZip);
$zipper->make("public/zips/{$nombreZip}")->add($imagenes);
return (response()->download($rutaZip, 'posts.zip'));