Home Laravel How To Download Multiple Files with Response in Laravel?

How To Download Multiple Files with Response in Laravel?

by Shahriar Sagor

Today now in this post i will show how to download multiple files with response in laravel? If we have to give allow to download multiple files with response from out application. If you need to give download only on file then we can do it very easily as like as this way:

return response()->download(public_path('myimage.jpg'));      

But if we need to give the multiple images files or docs etc then we can’t do it this way:

return response()->download([public_path('myimage.jpg'),public_path('myimage2.jpg')]);

But we must have to create the single zip file or something. So at first we need to use zipper package, i added the zipper package on my previous post you can install from here: Laravel Create and Download Zip File using chumper/zipper

Okay, now we can write the controller method on this way for download multiples response:

Controller Method

public function donwloadMultipleFile()
    return response()->download(public_path('mydir/mytest12.zip'));      

Read Also: Generate Captcha code and Validation by using BotDetect package in laravel

Thanks for read. I hope it help you. For more you can follow us on facebook


You may also like