laravel 5.1 error in validating doc docx type file

左心房为你撑大大i 提交于 2019-12-30 07:04:23

问题


Hi i am facing a docx type validation problem. I tried

$validator = Validator::make($request->all(), [
            'resume'   => 'mimes:doc,pdf,docx'
        ]);

It will upload pdf file with no error but whenever i try to upload docx files it gives validation error 'must be a file of type: doc, pdf, docx'
any idea


回答1:


thanks solved it by allowing zip

$validator = Validator::make($request->all(), [
            'resume'   => 'mimes:doc,pdf,docx,zip'
        ]);

this is because https://en.wikipedia.org/wiki/Office_Open_XML




回答2:


In Laravel 5.6.3., I have solved this using dot(.) sign:

$request->validate([
    'file.*' => 'required|file|max:5000|mimes:pdf,docx,doc',
]);


来源:https://stackoverflow.com/questions/33993874/laravel-5-1-error-in-validating-doc-docx-type-file

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!