The client asked me to limit the photos size uploaded by users to 1MB max .. I am using laravel 5.4 first, when I use $image->save() the size is automatically decreased and I don't know the reason second, is there a way to target the file size not the image dimensions size?
Asked
Active
Viewed 1,437 times
2 Answers
0
For limiting the size of an input file, you can use the size validation :
size:value
The field under validation must have a size matching the given value. For string data, value corresponds to the number of characters. For numeric data, value corresponds to a given integer value. For an array, size corresponds to the count
of the array. For files, size corresponds to the file size in kilobytes.
What is the difference between the 2 sizes ?

Community
- 1
- 1

Mathieu Ferre
- 4,246
- 1
- 14
- 31
0
$this->validate($request, [
'image' => 'required|image|mimes:jpeg,png,jpg,gif,svg|max:2048',
]);
check this link
http://itsolutionstuff.com/post/laravel-53-image-dimension-validation-rules-exampleexample.html

larsbadke
- 329
- 1
- 3
-
I want to automatically downgrade the size of the photo if it is larger than 1Mb – Omneya el-meligy Dec 13 '17 at 12:17