kekekiw123's avatar

Laravel require atleast one image to be uploaded

I am trying to setup validation to check if at least one images was uploaded and also only allow a maximum of 5 images. But does Laravel have any rule for this?

Atm, my rule looks like this

'images'=>'image|max:5400' checking that it is an image with a max-size of 5.4mb. But I would also like to check if at least one image was uploaded and also limit the upload to a maximum of 5 images.

I saw something about using "array" in my validation but wont that break my "image" rule?

0 likes
2 replies
bestmomo's avatar
Level 52

To check you have at least 1 image just add required and to check you have a maximum of 5 images make a custom validation with count(Input::get('images')) < 6

Please or to participate in this conversation.