refactor: 修改上传限制可配置
This commit is contained in:
@@ -27,9 +27,10 @@ class Upload
|
||||
}
|
||||
|
||||
try {
|
||||
$max_size = strtobytes(env('ADMIN_API.MAX_IMAGE_SIZE', '1mb'));
|
||||
$validate = validate([
|
||||
'module' => 'require|max:64',
|
||||
'image' => 'fileSize:1048576|fileExt:jpg,jpeg,png,gif'
|
||||
'image' => "fileSize:$max_size|fileExt:jpg,jpeg,png,gif"
|
||||
]);
|
||||
if (!$validate->check(['module' => $param['module'], 'image' => $file])) {
|
||||
return error($validate->getError());
|
||||
@@ -94,9 +95,10 @@ class Upload
|
||||
}
|
||||
|
||||
try {
|
||||
$max_size = strtobytes(env('ADMIN_API.MAX_VIDEO_SIZE', '100mb'));
|
||||
$validate = validate([
|
||||
'module' => 'require|max:64',
|
||||
'video' => 'fileSize:157286400|fileExt:mp4'
|
||||
'video' => "fileSize:$max_size|fileExt:mp4"
|
||||
]);
|
||||
if (!$validate->check(['module' => $param['module'], 'video' => $file])) {
|
||||
return error($validate->getError());
|
||||
@@ -148,8 +150,9 @@ class Upload
|
||||
}
|
||||
|
||||
try {
|
||||
$max_size = strtobytes(env('ADMIN_API.MAX_ATTACHMENT_SIZE', '100mb'));
|
||||
$validate = validate([
|
||||
'attachment' => 'fileSize:104857600|fileExt:zip,rar,7z,doc,docx,xls,xlsx,csv,ppt,pptx,pdf,txt'
|
||||
'attachment' => "fileSize:$max_size|fileExt:zip,rar,7z,doc,docx,xls,xlsx,csv,ppt,pptx,pdf,txt"
|
||||
]);
|
||||
if (!$validate->check(['attachment' => $file])) {
|
||||
return error($validate->getError());
|
||||
|
||||
Reference in New Issue
Block a user