hanif-king's avatar

it looks laravel mimes is not working or maybe i am doing the work in a wrong way

i have an ajax file upload which uploads multiple files to server . i have a validation rules as bellow

       $rules = [];
    $filesCount = count($request->files->get('files'))-1;
    for($i=0;$i<=$filesCount;$i++) {
        $rules['files.'. $i] = 'required|file|mimes:mp4,mp3|max:500000';
    }
      
        $error = Validator::make($request->all() , $rules);

this validation should only accept mp3 and mp4 files. but when i am checking if the validations is true or false by calling this method

 dd($error->fails());

the problem is that when i select a gif and mp4 type the validations gets passed and returns false. whereas it shouldn't be false because the validation rule is only for mp3 and mp4

note my codes working and i am successfully transferring files to the server in an array with name of 'files'

0 likes
0 replies

Please or to participate in this conversation.