LaraBABA's avatar

Laravel 6 Validator issue with multiple files(images and documents)

Hi all,

I have a project here the requires the user to upload any of the below types in a single upload file: pdf,jpeg,png,xlsx,doc,docx

The file is being sent from an axios post and receive as base64. When I use this rule and only upload images the validation works:

        $validator = Validator::make($request->all(), [
            'file' => 'image|mimes:jpeg,png,jpg|max:10240',
        ]);

But as soon as I try to mix both types(files and images) the validation failed:

        $validator = Validator::make($request->all(), [
            'file' => 'mimes:jpeg,png,jpg,docx,doc,pdf,xlsx|max:10240',
        ]);

Is there a way to check for all types at the same time?

Any why please?

Thank you.

0 likes
2 replies

Please or to participate in this conversation.