# 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);

 

相关文章:

  • 2021-09-30
  • 2021-06-01
  • 2021-09-23
  • 2022-12-23
  • 2021-11-18
  • 2021-11-18
  • 2021-11-18
  • 2021-11-18
猜你喜欢
  • 2022-01-12
  • 2021-12-29
  • 2021-12-27
  • 2021-10-09
  • 2021-11-18
  • 2021-11-18
  • 2022-02-11
相关资源
相似解决方案