5 months ago

create zip for multiple files by chumper/zipper Package

Posted 5 months ago by vinubangs

I have a table, that have some records with file name and that file save in a folder. Now I want to create zip file of selected file. I used chumper/zipper Package.

My controller is:

public function createzip($volume_id)
      $articles = article::where('volume_id',$volume_id)->get();

    $headers = ["Content-Type"=>"application/zip"];
        $fileName = ""; // name of zip
        foreach($articles as $article) {
        \Zipper::make(public_path('/storage/upload_pic/'.$article->image.'.zip')) //file path for zip file

                ->add(public_path()."storage/upload_pic/".$article->image)->close(); //files to be zipped
        return response()
        ->download(public_path($fileName),$fileName, $headers);

Please sign in or create an account to participate in this conversation.