http文件下载与404

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

 

转载于:https://www.cnblogs.com/jjxhp/p/10719078.html

你可能感兴趣的:(java)