ItSolutionStuff.com

Laravel Multiple Files Download with Response Example

By Hardik Savani • November 5, 2023
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.......

Tags: Laravel
Hardik Savani

Hardik Savani

I'm a full-stack developer, entrepreneur, and founder of ItSolutionStuff.com. Passionate about PHP, Laravel, JavaScript, and helping developers grow.

📺 Subscribe on YouTube

We Are Recommending You

Laravel Order By Multiple Columns Example

Read Now →

How to Automatically Generate Sitemap in Laravel?

Read Now →

How to Install Bootstrap in Laravel?

Read Now →

Laravel Fetch Data using Ajax Example

Read Now →

How to Add Password Protection for PDF File in Laravel?

Read Now →

How to Add Two Factor Authentication with SMS in Laravel?

Read Now →

Laravel Get Next and Previous Record with URL Example

Read Now →

Laravel Add Custom Configuration File Example

Read Now →

Laravel Send SMS to Mobile with Nexmo Example

Read Now →

Laravel Carbon Check If Date is Greater Than Other Date

Read Now →

How to Insert Multiple Records in Laravel?

Read Now →

How to Create Zip File in Laravel?

Read Now →

Laravel 5.2 multi auth example using Auth guard from scratch

Read Now →

Laravel Order By with Column Value Example

Read Now →