function addFileToZip($strPath, ZipArchive $pZip){
$filelist=scandir($strPath);
if(empty($filelist))die("空目录");
foreach ($filelist as $k => $filename) {
if ($filename != "." && $filename != ".."){
$pZip->addFile($strPath.$filename);
}
}
}
$tmpdir="uploads";
$strPath = '打包名称.zip';
try{
$pZip = new ZipArchive();
$pZip->open($strPath, ZipArchive::CREATE);
addFileToZip($tmpdir, $pZip);
$pZip->close();
}
catch (Exception $e){
throw new BusinessException('文件打包异常:'.$e->getMessage());
}
header("location:{$strPath}");die;