I'm trying to download a zip generated file but I'm getting a FileNotFoundException
, this is the code:
$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'));
I have already checked the file route that returns and the file is right there, with the same name and everything. Any ideas?
Try this:
$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'));