php实现文件下载的一段代码

$file_dir=$totalDirectory; $file_name=$filename; //echo
”./db/”.$file_dir.$file_name; if
(file_exists($file_dir.$file_name)){
$file=fopen($file_dir.$file_name,”r”);
Header(”Content-type:application/octet-stream”);
Header(”Accept-Ranges:bytes”);
Header(”Content-Disposition:attachment;filename=”.$file_name); echo
fread($file,filesize($file_澳门新葡亰网站注册,dir.$file_name)); fclose($file); exit;
}else{ echo ”file is not exists”; }