Search code examples
laravelzip

How to make a zip file containing two folders inside in laravel using Chumper/Zipper?


In my program two type of members can add images to the database and locally. There is a download function which will download all images (which were added by both members) as a zip file.

I need to make a zip file which contain two folders for both members using Chumper/Zipper in laravel. When I download the zip file it should contain two folders.


Solution

  • I have found the solution as following

            Zipper::make('uploads/staff/'.$order->bucket_name.'.zip')
                    ->folder('Retouch_files')->add($file_retouch)
                    ->folder('Cad_files')->add($file_cad)
                    ->close();
    

    By using '->folder('folder_name')->add(file_you_want_to_add_inside)' we can create any amount of folders.