mirror of
https://github.com/solidtime-io/solidtime.git
synced 2026-08-08 00:02:15 +01:00
add 1MB photo upload limit
This commit is contained in:
committed by
Constantin Graf
parent
e29be581fa
commit
cb8047028c
@@ -16,6 +16,8 @@ class Base64ImageRule implements ValidationRule
|
||||
'image/png',
|
||||
];
|
||||
|
||||
private const int MAX_BYTES = 1024 * 1024;
|
||||
|
||||
/**
|
||||
* Run the validation rule.
|
||||
*
|
||||
@@ -32,6 +34,12 @@ class Base64ImageRule implements ValidationRule
|
||||
$file = Base64File::decode($value);
|
||||
if ($file === null || ! in_array($file['mime_type'], self::ALLOWED_MIME_TYPES, true)) {
|
||||
$fail(__('validation.mimes', ['values' => 'jpg, png']));
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (strlen($file['data']) > self::MAX_BYTES) {
|
||||
$fail(__('validation.max.file', ['max' => (string) (self::MAX_BYTES / 1024)]));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user