refactor: 后台图片上传添加允许webp格式

This commit is contained in:
2025-06-27 09:54:30 +08:00
parent 239bb64e9a
commit a29e95a951

View File

@@ -31,7 +31,7 @@ class Upload
$max_size = strtobytes(env('ADMIN_API.MAX_IMAGE_SIZE', '1mb')); $max_size = strtobytes(env('ADMIN_API.MAX_IMAGE_SIZE', '1mb'));
$validate = validate([ $validate = validate([
'module' => 'require|max:64', 'module' => 'require|max:64',
'image' => "fileSize:$max_size|fileExt:jpg,jpeg,png,gif" 'image' => "fileSize:$max_size|fileExt:jpg,jpeg,png,gif,webp"
]); ]);
if (!$validate->check(['module' => $param['module'], 'image' => $file])) { if (!$validate->check(['module' => $param['module'], 'image' => $file])) {
return error($validate->getError()); return error($validate->getError());
@@ -346,7 +346,7 @@ class Upload
try { try {
$max_size = strtobytes(env('ADMIN_API.MAX_ATTACHMENT_SIZE', '100mb')); $max_size = strtobytes(env('ADMIN_API.MAX_ATTACHMENT_SIZE', '100mb'));
$validate = validate([ $validate = validate([
'attachment' => "fileSize:$max_size|fileExt:biz,bz,bz2,gz,tgz,zip,rar,7z,doc,docx,xls,xlsx,csv,ppt,pptx,pdf,txt,jpg,jpeg,png,ttf" 'attachment' => "fileSize:$max_size|fileExt:biz,bz,bz2,gz,tgz,zip,rar,7z,doc,docx,xls,xlsx,csv,ppt,pptx,pdf,txt,jpg,jpeg,png,.webp,ttf"
]); ]);
if (!$validate->check(['attachment' => $file])) { if (!$validate->check(['attachment' => $file])) {
return error($validate->getError()); return error($validate->getError());