laravel validate attach image number How check validate attach image number ?
$request->validate([
'image.*.*' => 'mimes:jpeg,jpg,png,gif|max:2048',
]);
Hey.
I think, you need two validations here:
$request()->validate([
'image' => 'max:5', // check the length of the array
'image.*.*' => 'mimes:jpeg,jpg,png,gif|max:2048', // checks file size, type etc.
]);
Did you copy that 1:1? Because i made a mistake.
Here is the correct version:
$request->validate([
'image' => 'max:5', // check the length of the array
'image.*.*' => 'mimes:jpeg,jpg,png,gif|max:2048', // checks file size, type etc.
]);
Do you get an errors when validatiing your input?
Hi
no error I can upload more then 5 images
Why image.*.*?
$request->validate([
'image' => 'array|min:1|max:5',
'image.*' => 'mimes:jpeg,jpg,png,gif|max:2048'
]);
Why image.*.*? -I use this
<input type="file" id="image" name="image[1][]" class="form-control" multiple>
<input type="file" id="image" name="image[2][]" class="form-control" multiple>
find solution
'image.*' => 'max:30',
'image.*.*' => 'mimes:jpeg,jpg,png,gif|max:2048',
@www888 The id attribute has to be unique.
By the way I gave you a correct solution, it was just without one level.
it must be like this ?
'image.*' => 'array|max:2',
In your case yes, I added array validation rule to be clear that you have an array.
Please sign in or create an account to participate in this conversation.