Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

afraz's avatar
Level 3

How to make validation rules to upload pdf, doc and docx files in laravel 5.4

How to make validation rules to upload pdf, doc and docx files in laravel 5.4

Tried: 'fileUpload' => 'required|mimes:jpeg,png,jpg,doc,docx,pdf|max:2048',

But doc and docx are not working.

0 likes
3 replies
afraz's avatar
Level 3

Thanks, actually doc and docx are zip files so I added zip instead of doc, docx and its working. 'fileUpload' => 'required|mimes:jpeg,png,jpg,zip,pdf|max:2048',

2 likes
rapa's avatar

For Laravel 7+ to validate doc, docx you need to create mimes.php in config directory and add the following content,

config/mimes.php

<?php
 
return [
    'doc'  => array('application/msword', 'application/vnd.ms-office'),
    'docx' => array('application/vnd.openxmlformats-officedocument.wordprocessingml.document', 'application/zip'),
];

Please or to participate in this conversation.