PHP之HEADER隐藏文件下载路径
2017-01-24 14:50
417 查看
说明:主要是利用readfile函数将文件另存下载
<? $file="material_upload/Adobe Dreamweaver CS5.zip"; //$file里面必须是真实的下载路径 if(file_exists($file)) { header('Content-Description: File Transfer'); header('Content-Type: application/octet-stream'); header('Content-Disposition: attachment; filename='.basename($file)); header('Content-Transfer-Encoding: binary'); header('Expires: 0'); header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); header('Pragma: public'); header('Content-Length: ' .filesize($file)); ob_clean(); flush(); readfile($file); exit; } ?>
相关文章推荐
- 一个关于if else容易迷惑的问题
- PHP5.2.*防止Hash冲突拒绝服务攻击的Patch
- 深入理解PHP之匿名函数
- JSP/PHP基于Ajax的分页功能实现
- 关于PHP通过PDO用中文条件查询MySQL的问题。
- 什么是设计模式
- PHP数据库长连接mysql_pconnect的细节
- Php Installing An Expansion
- Laravel5.3 表单验证中文报错提示语言包
- 10 件在 PHP 7 中不要做的事情
- 写程序的时候应该如何思考?
- rem : web app适配的秘密武器
- jquery高级应用之Deferred对象
- 关于浮动与清除浮动,你应该知道的
- 数组reduce方法的高级技巧
- php7 读取php.ini[4]
- PHP-max_execution_time与fpm.request_terminate_timeout介绍
- PHP+Apache在Windows 9x下的安装和配置