I have multiple input fields with multiple file upload for each field.
<?php for ($i = 0; $i < $total; $i++)
{
?>
<div class="col-md-3 addedClass">
<label>Vehicle Images</label>
<input type="file" name="vehicle_image[{{$i}}][]" multiple="multiple">
@if($errors->has('vehicle_image'))
<span class="help-block">
<strong>{{$errors->first('vehicle_image')}}</strong>
</span>
@endif
</div>
<?php } ?>
I have got files in the request like this:
"vehicle_image" => array:2 [▼
0 => array:2 [▼
0 => "citizenship.jpg"
1 => "logo_vehicle.png"
]
1 => array:2 [▼
0 => "ae backend.jpg"
1 => "logo_vehicle.png"
]
]
In this case, I have two input fields with 2/2 files. When I have tried to validate mime type for only images
like this:
$this->validate($request,[
'vehicle_image' => 'mimes:jpeg,png,bmp,tiff |max:4096'
],$messages[
// error messages
]);
I have got following error:
FatalThrowableError in ReservationController.php line 67: Cannot use [] for reading
Can someone tell me what is wrong with the above code ? Suggestions are appreciated.