首页 | 源码下载 | 网站模板 | 网页特效 | 广告代码 | 网页素材 | 字体下载 | 书库 | 站长工具
会员投稿 投稿指南 RSS订阅
当前位置:主页>网络编程>PHP教程>资讯:php运用readfile函数给隐藏下载文件地址增加权限判断

php运用readfile函数给隐藏下载文件地址增加权限判断

www.jz123.cn  2012-04-11   来源:   站长家园    责任编辑(袁袁)    我要投递新闻

<?php 02$file = get_file_address();// 文件的真实地址(支持url,不过不建议用url) 0304if (file_exists($file)) { 05header(&#39;Content-Description: File Transfer&#39;); 06header(&#39;Conte...

  1 以上代码实现了真是URL路径的隐藏功能, 本页开头可以进行权限判断。

  2 效果如图,我们看到下面文件下载的URL已经被test.php隐藏.

  

<?php 02 $file = get_file_address();// 文件的真实地址(支持url,不过不建议用url)
03
04 if (file_exists($file)) {
05 header('Content-Description: File Transfer');
06 header('Content-Type: application/octet-stream');
07 header('Content-Disposition: attachment; filename='.basename($file));
08 header('Content-Transfer-Encoding: binary');
09 header('Expires: 0');
10 header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
11 header('Pragma: public');
12 header('Content-Length: ' . filesize($file));
13 ob_clean();
14 flush();
15 readfile($file);
16 exit;
17 }
18 ?>

上一篇:手把手教你Smarty缓存技术 下一篇:Openbiz 实现 PHP的元数据编程

评论总数:0 [ 查看全部 ] 网友评论


关于我们隐私版权广告服务友情链接联系我们网站地图