【发布时间】:2021-10-31 15:18:26
【问题描述】:
upload 文件夹中有 3 个子文件夹。我的代码如下所示:
if(isset($_SESSION["u_type"]) && $_SESSION["u_type"] == 3) {
$files = scandir($path."/3/") //$path is set somewhere above
//...
}
它工作正常,但您实际上可以添加一个简单的 html 标记,例如 <img src="uploads/2/somathing.png/> ,即使您的“用户类型”设置为 3,您也可以从子目录 2 获取任何文件。
有没有办法预防?
我已经试过了:
我正在使用带有Options- Indexes 的 .htacces,但它只会缩短文件的直接列表。
【问题讨论】:
标签: php security session directory