# http文件下载与404

if (!file_exists($file_path)) {
    header('HTTP/1.1 404 Not Found');
    header("status: 404 Not Found");
    http_response_code(404);
    exit(404);
}
header( 'Content-Disposition:  attachment;  filename='.basename($file_path));
header('Content-Length: ' . filesize($file_path));
ob_clean();
flush();
readfile($file_path);

 

SRE实战 互联网时代守护先锋,助力企业售后服务体系运筹帷幄!一键直达领取阿里云限量特价优惠。
扫码关注我们
微信号:SRE实战
拒绝背锅 运筹帷幄