Home > Backend Development > PHP Tutorial > PHP 上载文件隐藏路径,做过文件上载安全性的进来看看哦

PHP 上载文件隐藏路径,做过文件上载安全性的进来看看哦

WBOY
Release: 2016-06-13 13:20:59
Original
805 people have browsed it

PHP 下载文件隐藏路径,做过文件下载安全性的进来看看哦!
最近在弄文件资源管理,在下载时隐藏文件路径采用的方案仅仅是,对存放文件的目录用apache配置使之无法直接访问目录列表,rewrite技术可隐藏服务器的目录!
比如下载路径本来为:http://miresearch.cn/uploadfile/resource/2012-05/8F4F5A42-1B4C-8B80-0EFC-9FF2346373BF.rar
如果不做出来,直接访问http://miresearch.cn/uploadfile/resource/2012-05这个可以查看服务器此目录下的所有文件,后来经过了apache配置使http://miresearch.cn/2012-05/8F4F5A42-1B4C-8B80-0EFC-9FF2346373BF.rar可以实现下载文件以隐藏服务器目录,且http://miresearch.cn/2012-05此目录不能直接访问。

初学者对文件下载仅仅做了这么点工作,请各位高手看看,有什么好建议方案,给小弟指导下~有做过文件下载的安全性请过来看看,指引下哦~

------解决方案--------------------
帐号密码验证后直接输出文件...

例如

PHP code

header('Content-Type: application/octet-stream');
$filesize = filesize('s.png'); //获得文件大小
header('Last-Modified: '.gmdate('D, d M Y H:i:s') . ' GMT');
header('Cache-Control: no-store, no-cache, must-revalidate');
header('Cache-Control: pre-check=0, post-check=0, max-age=0');
header('Content-Transfer-Encoding: binary');
header('Content-Encoding: none');
header('Content-type: application/force-download');
header('Content-length: '.$filesize);
header('Content-Disposition: attachment; filename="s.png"');
readfile('s.png'); <div class="clear">
                 
              
              
        
            </div>
Copy after login
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template