I am using PHP 5.5.9. I need to download password protected zip file. I am using zip archive setPassword method. But its showing error undefined method setPassword. Can please anyone help me. Below I mentioned whatever I done.
$excelName = 'DownloadDocument_'.Carbon::now()->format('dmY');
$filename = storage_path('app/zipFolder/').'DownloadDocument_'.Carbon::now()->format('dmY').'.zip';
if ($zip->open($filename, ZipArchive::CREATE) == TRUE) {
$zip->addFile(storage_path('app/fileFolder/').$excelName.'.xls', 'newname.xls');
$zip->setPassword("secret");
$zip->close();
}
The ZipArchive::setPassword method only exists in PHP version 5.6.0 or higher. Since you are using PHP version 5.5.9 this method is not available in your PHP installation.