根据权限 下载文件

来源:互联网 发布:板金放样展开图软件 编辑:程序博客网 时间:2024/06/03 17:42

1. [代码][PHP]代码   

view source
print?
01<?php  
02$file = '*****.jpg';// 文件的真实地址  
03   
04if (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?>

2. [代码][HTML]代码     

1以上代码实现了真是URL路径的隐藏功能, 本页开头可以进行权限判断。
2效果如图,我们看到下面文件下载的URL已经被test.php隐藏
0 0
原创粉丝点击