0
votes

I'm getting following Error while to creating Zip file in laravel using ZipArchive which will have all the PDF files

"Undefined property: ZipArchive::$close"

CONTROLLER:

public function downloadZip(Request $request)
    {            
            @$job_id = $request->job_id;
            @$filenames = DB::table('analytics_report')->where('job_id',$job_id)->get()->pluck('filename')->toArray();
            @$zipname = $request->job_id;
            $zip = new \ZipArchive;
            $zip->open($zipname, \ZipArchive::CREATE);
            foreach ($filenames as $filename){
                $zip->addFile($filename);
            }
            $zip->close;
            @$path = '../storage/app/public/bks/case_1/'.$zipname;
     }
1

1 Answers

3
votes
$zip->close();

You're missing the parantheses to make it a function call - currently you're trying to access a property $close on $zip, which doesn't exist.