php如何通过header文件头实现文件下载

$file = $_GET['file'];
if(file_exists($file)){
header("Content-type:application/octet-stream");
$filename = basename($file);
header("Content-Disposition:attachment;filename = ".$filename);
header("Accept-ranges:bytes");
header("Accept-length:".filesize($file));
readfile($file);
}else{
    echo "";
}

你可能感兴趣的:(PHP)