Set max file sizes on products
This commit is contained in:
parent
99f7545595
commit
c450d71bed
2 changed files with 9 additions and 0 deletions
|
|
@ -69,6 +69,10 @@ trait HasDocumentAndPictureList
|
|||
'mimetypes' => Str::of($this->autorisedMimTypes)->implode(' ou ')
|
||||
]));
|
||||
}
|
||||
$maxSize = 6 * 1024 * 1024;
|
||||
if (File::size($value) > $maxSize) {
|
||||
$fail(trans(':attribute doit être inférieur à :size Mo', ['size' => $maxSize / (1024 * 1024)]));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -138,6 +138,11 @@ trait HasPicture
|
|||
) {
|
||||
$fail(trans(":attribute doit être une image de type 'image/jpeg,image/jpg,image/png,image/gif'"));
|
||||
}
|
||||
$filesize = \filesize($fileFullPath);
|
||||
$maxSize = 6 * 1024 * 1024;
|
||||
if ($filesize === false || $filesize > $maxSize) {
|
||||
$fail(trans(':attribute doit être inférieur à :size Mo', ['size' => $maxSize / (1024 * 1024)]));
|
||||
}
|
||||
if (!($dimensions = \getimagesize($fileFullPath)) or !isset($dimensions[0]) or !isset($dimensions[1])) {
|
||||
$fail(trans(":attribute impossible de valider les dimensions"));
|
||||
} else {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue