Laravel Create and Download Zip File Example using chumper/zipper

Laravel Create and Download Zip File Example using chumper/zipper

In this post we will give you information about Laravel Create and Download Zip File Example using chumper/zipper. Hear we will give you detail about Laravel Create and Download Zip File Example using chumper/zipperAnd how to use it also give you demo for it if it is necessary.

Sometimes, we need to create file of our project directory and give to download that zip file to users. we are always prefer zip file because it is very safe and secure from virus. If you want to generate zip file and donwload that file in your laravel 5 application then you do it easily using chumper/zipper composer package. In this post i give you example to create zip file and donwload from scratch. So first we have to follow bellow step for install package.

First fire following command on your terminal.

Installation Package

composer require chumper/zipper

After install this package, Now open config/app.php file and add service provider and aliase.

config/app.php

'providers' => [

....

'ChumperZipperZipperServiceProvider',

],

'aliases' => [

....

'Zipper' => 'ChumperZipperZipper'

],


ok, now we are ready to use Zipper class globally. So now use can use how to create zip file and download it that write in your controller this way. i added controller function for doneload zip file so you can use anyway.

Make sure you have two folder in your public directory:

1.js(with some files)

2.mydir(store zip file here)

Controller Method

Also see:Laravel 5.3 Image Upload with Validation example

public function downloadZip()

{

$files = glob(public_path('js/*'));

Zipper::make('mydir/mytest3.zip')->add($files);


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

}

Try this it will help you and for more information click here: Zipper.

Hope this code and post will helped you for implement Laravel Create and Download Zip File Example using chumper/zipper. 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 *

2  +  1  =  

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