php 下载本地文件
<?
$file_name = "要下载的文件名字";
$file_dir = "要下载的文件目录";
if (!file_exists($file_dir . $file_name)) { //检查文件是否存在
echo "文件找不到";
exit;
} else {
$file = fopen($file_dir . $file_name,"r"); //打开文件
//输入文件标签
Header("Content-type: application/octet-stream");
Header("Accept-Ranges: bytes");
Header("Accept-Length: ".filesize($file_dir . $file_name));
Header("Content-Disposition: attachment; filename=" . $file_name);
//输出文件内容
echo fread($file,filesize($file_dir . $file_name));
fclose($file);
}
?>
标签: 下载 php 下载本地文件 php 下载 php 下载文件
热门日志
分类
- Django(4)
- ssdb(1)
- Mac(7)
- C(1)
- memcache(1)
- Python(32)
- Vim(8)
- sed(2)
- ansible(3)
- awk(4)
- shell(3)
- about(1)
- git(9)
- bat(4)
- svn(0)
- docker(1)
- Tornado(1)
- go(2)
- 架构(19)
- Vue(1)
- game(2)
- Html(6)
- Java(8)
- Mysql(38)
- Ajax(2)
- Jsp(1)
- Struts(8)
- Linux(73)
- JavaScript(39)
- Staruml(0)
- Mouth(1)
- Php(102)
- Windows(8)
- Message(48)
- Lua(10)
- Compute(1)
- Redis(7)
- Nginx(12)
- Jquery(1)
- Apache(1)
- cocos2d-x(8)
最新日志
随机日志
- php-fpm通过request_slowlog_timeout检查哪个脚本执行时间长
- 永远不要在 Linux 执行的 10 个最危险的命令
- js 实现php中sprintf函数
- Js中window.parent ,window.top,window.self 详解
- Warning: Unknown: Unable to allocate memory for pool. in Unknown on line 0 Warning: require_once(): Unable to allocate memory for pool
- Jquery跨域请求php获取数据之jsonp
- apache 开启gzip压缩和http缓存的配置方法
- linux gz 解压缩