Skip to content

Commit

Permalink
修改文件上传,文件后缀验证机制
Browse files Browse the repository at this point in the history
  • Loading branch information
zoujingli committed Sep 15, 2021
1 parent b1fab14 commit 0bf173c
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion app/admin/controller/api/Upload.php
Expand Up @@ -112,7 +112,7 @@ public function file()
$extension = strtolower($file->getOriginalExtension());
$saveName = input('key') ?: Storage::name($file->getPathname(), $extension, '', 'md5_file');
// 检查文件后缀是否被恶意修改
if (ltrim(strtolower(strrchr($saveName, '.')), '.') !== $extension) {
if (pathinfo(parse_url($saveName, PHP_URL_PATH), PATHINFO_EXTENSION) !== $extension) {
$this->error('文件后缀异常,请重新上传文件!');
}
// 屏蔽禁止上传指定后缀的文件
Expand Down

0 comments on commit 0bf173c

Please sign in to comment.