Laravel 5 - multiple files download with response example

By Hardik Savani | May 14, 2016 | | 55761 Viewer | Category : Laravel


If you need to give to download multiple files response from out application. If you require to give download only on file then you can do it easily like this way:

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

But if you need to give multiple images files or docs etc then you can't do it this way:

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

But you must have to create single zip file or something. So first you need to use zipper package, i added zipper package on my previous post you can install from here : Laravel 5 create and download zip file example using chumper/zipper composer package

Ok, now you can write controller method this way for download multifiles response:

Controller Method

public function donwloadMultipleFile()

{

Zipper::make('mydir/mytest12.zip')->add(['thumbnail/1461610581.jpg','thumbnail/1461610616.jpg']);

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

}

Try this way it can help you.......



Hardik Savani
My name is Hardik Savani. I'm a full-stack developer, entrepreneur and owner of Aatman Infotech. I live in India and I love to write tutorials and tips that can help to other artisan. I am a big fan of PHP, Javascript, JQuery, Laravel, Codeigniter, VueJS, AngularJS and Bootstrap from the early stage.
Follow Me: Github Twitter
***Do you want me hire for your Project Work? Then Contact US.


We are Recommending you: