Laravel – Multiple Files Download with Response Example

Laravel – Multiple Files Download with Response Example

In this post we will give you information about Laravel – Multiple Files Download with Response Example. Hear we will give you detail about Laravel – Multiple Files Download with Response ExampleAnd how to use it also give you demo for it if it is necessary.

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

Also see:How to Insert Multiple Records in Laravel?

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…….

Hope this code and post will helped you for implement Laravel – Multiple Files Download with Response Example. if you need any help or any feedback give it in comment section or you have good idea about this post you can give it comment section. Your comment will help us for help you more and improve us. we will give you this type of more interesting post in featured also so, For more interesting post and code Keep reading our blogs

For More Info See :: laravel And github

Leave a Comment

Your email address will not be published. Required fields are marked *

  +  39  =  40

We're accepting well-written guest posts and this is a great opportunity to collaborate : Contact US