作者 开飞机的舒克

后台修改

... ... @@ -194,40 +194,4 @@ class Study extends Backend
$this->success();
}
/**
* 批量下载
*/
public function download($ids)
{
$list = $this->model->where('id ', 'in', $ids)->select();
$zip = new \ZipArchive;
$filename = 'tmp/' . date('Ymd',time()) . '_u' . $this->auth->id . '_reports.zip';
if ($zip->open($filename,\ZipArchive::CREATE | \ZipArchive::OVERWRITE) === TRUE){
foreach ($list as $publish) {
$filepath = 'uploads' . 'l' . $publish->file;
if (!file_exists($filepath)) {
$this->error($publish->code . '文件未找到');
}else {
$zip->addFile($filepath, basename($filepath));
}
}
}
//打包zip
$zip->close();
if (!file_exists($filename)) {
$this->error('创建下载文件失败!');
}
Header("Cache-Control : public");
Header("Content-type: application/octet-stream");
// Header("Content-type: application/zip");
header("Content-Transfer-Encoding : binary");
Header("Accept-Length: " . filesize($filename));
Header( "Cache-Control : public");
Header( "Content-type: application/octet-stream");//Header( "Content-type: application/zip");
header( "Content-Transfer-Encoding: binary");
Header( "Accept-Length: " . filesize($filename));
Header("Content-Disposition: attachment; filename=" . basename($filename));//输出文件内容
readfile($filename);flush();
// return json(0);
}
}
... ...