lavina's avatar

Validation

Hello, i have a file upload field:

<input type="file" name="videos[]" id="videos" accept="video/*" multiple>

I have controller:

    public function addVehicle(VehicleRequest $request, $category, $id)
    {
        dd($request);
}

And VehicleRequest with rules:

        return [
            'videos.*' => 'required|file|mimes:mp4,mov,og,wmv,flv,avi',
        ];

If file type is wrong, it fails validation, if lefty empty it passes, why is this happening??

0 likes
3 replies
Sergiu17's avatar

name="modelF[]" and 'videos.*' should match

lavina's avatar

You are definetly right sir, copy pasted the wrong input field, updated the field name to the real name : 'videos[]'

Sergiu17's avatar
Sergiu17
Best Answer
Level 60

and add a rule for videos too

'videos' => 'required',
'videos.*' => 'required|file|mimes:mp4,mov,og,wmv,flv,avi',

Please or to participate in this conversation.