<?php
header("Content-type:text/html;charset=utf-8");
$file_name="1.jpg";
$file_sub_path=str_replace('\\','/',dirname(__FILE__)).'/';//当前文件的路径
$file_path=$file_sub_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-Ranges: bytes");
Header("Accept-Length:".$file_size);
Header("Content-Disposition: attachment; filename=".$file_name);
$file_con=fread($fp,$file_size);
fclose($fp);
echo $file_con;
?>
本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请
点击举报。