<?php  
$file = get_file_address();// 文件的真实地址(支持url,不过不建议用url)  
 
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;  
}  
?>
以上代码实现了真是URL路径的隐藏功能, 本页开头可以进行权限判断。
效果如图,我们看到下面文件下载的真实URL已经被test.php隐藏