0

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?

Connell.O'Donnell
  • 3,603
  • 11
  • 27
  • 61
Omneya el-meligy
  • 103
  • 1
  • 1
  • 14

2 Answers2

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