Show image upload validation errors I can't show validation errors in a form that allows multiple images to be uploaded. It only shows the "Required" error, but those about the maximum size or extensions allowed don't show them.
Where am I wrong?
$request->validate([
'image' => 'required',
'image.*' => 'mimes:jpeg,jpg,png|max:2048'
]);
@error('image')
<span class="invalid-feedback" role="alert">
<strong>{{ $message }}</strong>
</span>
@enderror
@if ($errors->first('image') || $errors->first('image.*'))
<span class="invalid-feedback" role="alert">
<strong>{{ $message }}</strong>
</span>
@endif
Edit: oops my bad, $message only exists when use @error
this should work
@if ($errors->hasAny(['image', 'image.*']))
<span class="invalid-feedback" role="alert">
<strong>{{ $errors->first('image') ?: $errors->first('image.*') }}</strong>
</span>
@endif
Please sign in or create an account to participate in this conversation.