vladshoob's avatar

How to validate .docx file?

I'm trying to upload .docx file with this code:

        $validated = $request->validate([
            'file' => 'mimes:application/vnd.openxmlformats-officedocument.wordprocessingml.document'
        ]);

dd($request) shows me this mime for a file, but for some reason it is not validated. I tried to add zip, app.../msword, docx mimes to validation rules, but not successfully.

Thanks in advance.

0 likes
2 replies
rahoo303's avatar

You can use like below

$validated = $request->validate([ 'file' => 'mimetype:image/jpeg,application/octetstream.application/msword.application/vnd.oasis.opendocument.text' ]);

Please or to participate in this conversation.