I have used single validation rule only for file input field. That is mimes rule. I wanted to skip this rule if no file is uploaded, so i have not used 'required' rule. But it is always showing mime type message even if no file is uploaded. I have just added required rule for testing , at that time it shown required error message. This problem is only when submitting form using ajax with jquery.form.js
You can use the sometimes validation type for that.
'file' => 'sometimes|mimes:jpeg,png'
Validating When Present
In some situations, you may wish to run validation checks against a field only if that field is present in the input array. To quickly accomplish this, add the sometimes rule to your rule list.
Official Laravel docs
You can use sometimes rule.
'photo' => 'sometimes|mimes:jpeg,bmp,png'
You can check more about it here https://laravel.com/docs/5.4/validation#conditionally-adding-rules
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With