21,886
社区成员
发帖
与我相关
我的任务
分享
function down_file($file_name,$file_path){
@$file_name=iconv("utf-8","gb2312",$file_name);
$file_path=$_SERVER['DOCUMENT_ROOT'].$file_path.$file_name;
if(!file_exists($file_path)){
echo "文件不存在";
return;
}
$fp=fopen($file_path,"r+");
$file_size=filesize($file_path);
header("Content-type: application/octet-stream");
header("Accept-Rangers: bytes");
header("Accept-Length: $file_size");
header("Content-Disposition: attachment;filename=".$file_name);
while(!feof($fp)){
$data=fread($fp,1024);
echo $data;
}
fclose($fp);
}
down_file("php.png","/down/");