Home > Back-end >  Laravel 8 I cant verify image type
Laravel 8 I cant verify image type

Time:12-09

Hello I can't verify my image type with mimes:jpg,jpeg,png

I am sending this to api

"images": [
    {
      "imageId": 0,
      "size": 1036822,
      "name": "scott-webb-hDyO6rr3kqk-unsplash.jpg",
      "type": "jpeg",
      "belongsTo": 0
    }
  ]

before this type was 'image/jpeg'

but I get the same error:

images.0.type: Array(1)
0: "The images.0.type must be a file of type: jpeg, jpg."

This is validation:

$request->validate([
    'images.*.type' => 'mimes:jpeg,jpg',
]);

CodePudding user response:

try this

$this->validate($request, ['image' => 'image|mimes:jpeg,png,jpg,gif,svg|max:2048',]);

  • Related