PHP文件下载
来源:互联网 发布:冒险岛2装备数据库 编辑:程序博客网 时间:2024/06/15 18:42
<?php
header('Content-type:text/html;charset=utf-8');
$file_path = './images/beauty.jpg';
file_exists($file_path) or die('文件不存在');//判断文件是否存在
//文件信息
$file_size = filesize($file_path);
$file_name = basename($file_path);
//以只读方式打开文件
$fp = fopen($file_path,'r');
header("Content-type:application/octet-stream");
header("Accept-Ranges:bytes");
header("Accept-Length:".$file_size);
header("Content-Disposition:attachment;filename=".$file_name);
$content = fread($fp,$file_size);
//若文件过大,也可以每次只读取1024字节
/*
$content = '';
while(!feof($fp)){
$content .= fread($fp,1024);
}
*/
echo $content;
?>
header('Content-type:text/html;charset=utf-8');
$file_path = './images/beauty.jpg';
file_exists($file_path) or die('文件不存在');//判断文件是否存在
//文件信息
$file_size = filesize($file_path);
$file_name = basename($file_path);
//以只读方式打开文件
$fp = fopen($file_path,'r');
header("Content-type:application/octet-stream");
header("Accept-Ranges:bytes");
header("Accept-Length:".$file_size);
header("Content-Disposition:attachment;filename=".$file_name);
$content = fread($fp,$file_size);
//若文件过大,也可以每次只读取1024字节
/*
$content = '';
while(!feof($fp)){
$content .= fread($fp,1024);
}
*/
echo $content;
?>
0 0
- PHP实现文件下载
- PHP实现文件下载
- PHP实现文件下载
- php 文件下载类
- php自动下载文件
- php下载文件代码
- PHP实现文件下载
- 关于PHP文件下载
- PHP强制性文件下载
- php 下载文件代码
- PHP下载文件
- php下载文件
- php强制下载文件
- php下载文件
- php下载文件
- php下载文件方法
- php下载文件
- PHP下载文件代码
- 公司的一些习惯
- Spring Bean的生命周期
- Anaconda安装
- php原生态验证码
- 【模板】线段树
- PHP文件下载
- 定时跳转
- 1.并发情况导致的线程阻塞和数据一致性问题
- N: Ignoring file '50unattended-upgrades.ucf-dist' in directory '/etc/apt/apt.conf.d/' as it has an i
- linux 后台执行命令
- C++中二维数组的使用
- 降级GCC版本记录:error : libc_name_p
- Android之多媒体技术
- 1-1.线程阻塞