Published 2 years ago by lorvent
In 5.3, How can i validate an image only if its uploaded.
a rule like
'pic_file' => 'mimes:jpg,jpeg,bmp,png|max:10000',
pic_file only if its uploaded in 5.2
but in 5.3, i am getting error as image extension is wrong eventhough i didn't upload image.
how can i make validation optional? or how i can add a rule dynamically in Requests (not in controller)
I think the rule should like so-
'image' => 'required|image|mimes:jpeg,png,jpg,gif,svg|max:2048'
Can be helpful this tutorial- http://itsolutionstuff.com/post/laravel-53-image-upload-with-validation-exampleexample.html