根据 php 手册,我已经在 php.ini 文件中启用了 php_zip.dll,并在 php 安装文件夹的 ext 文件夹中检查了 php_zip.dll。它出现在那里。但是在使用 zip 代码时,它会显示如下错误:
Fatal error: Class 'ZipArchive' not found in C:\inetpub\wwwroot\projectname\bulkdownload.php on line 9
以下是批量下载.php的代码
<?php
function zipFilesAndDownload($file_names,$archive_file_name,$file_path)
{
$zip = new ZipArchive();
//create the file and throw the error if unsuccessful
if ($zip->open($archive_file_name, ZIPARCHIVE::CREATE )!==TRUE) {
exit("cannot open <$archive_file_name>\n");
}
//add each files of $file_name array to archive
foreach($file_names as $files)
{
$zip->addFile($file_path.$files,$files);
}
$zip->close();
//then send the headers to foce download the zip file
header("Content-type: application/zip");
header("Content-Disposition: attachment; filename=$archive_file_name");
header("Pragma: no-cache");
header("Expires: 0");
readfile("$archive_file_name");
exit;
}
$file_array = $_GET['voice'];
$file_names = explode(';', $file_array);
$archive_file_name = "voicefile.zip";
$file_path = "d:/temp_file/voice/";
zipFilesAndDownload($file_names,$archive_file_name,$file_path);
?>