public function download(){
$id=$this->request->get['download_id'];
if($id){
$file_name=getDownloadFileName($id);
$file_path="download/".$file_name;
if (file_exists($file_path)) {
header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename='.basename($file_path));
header('Content-Transfer-Encoding: binary');
header('Expires: 0');
header('Cache-Control: must-revalidate');
header('Pragma: public');
header('Content-Length: ' . filesize($file_path));
ob_clean();
flush();
readfile($file_path);
}
}
}
PHP实现文件下载
最新推荐文章于 2023-12-12 11:50:29 发布