mirror of
https://gitee.com/zoujingli/ThinkAdmin.git
synced 2025-04-06 03:58:04 +08:00
修改文件上传,文件后缀验证机制
This commit is contained in:
parent
b1fab14623
commit
0bf173c5d7
@ -112,7 +112,7 @@ class Upload extends Controller
|
|||||||
$extension = strtolower($file->getOriginalExtension());
|
$extension = strtolower($file->getOriginalExtension());
|
||||||
$saveName = input('key') ?: Storage::name($file->getPathname(), $extension, '', 'md5_file');
|
$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('文件后缀异常,请重新上传文件!');
|
$this->error('文件后缀异常,请重新上传文件!');
|
||||||
}
|
}
|
||||||
// 屏蔽禁止上传指定后缀的文件
|
// 屏蔽禁止上传指定后缀的文件
|
||||||
|
Loading…
x
Reference in New Issue
Block a user