public function file_down($id){
if(empty($_GET['id'])){
redirect("文件不存在跳转页面");
}else{//如果要加登录条件,这里可以自己加
$dl=D('downlist');
$map['id'] = array('eq',$_GET['id']);
$list=$dl->where($map)->find();
if ($list == false) {//文件不存在,可以跳转到其它页面
header('HTTP/1.0 404 Not Found');
header('Location: .');
} else {
header("Expires: ".gmdate("D, d M Y H:i:s", time() + 3600000)." GMT");
header('Content-type:application/octet-stream', true);
echo($list["file_zip"]);//file_zip为打包文件字段
}
}
}
//注:字段file_zip需要使用ZipArchive打包存储 最佳答案