primefaces fileupload invalid file type doc, docx

不打扰是莪最后的温柔 提交于 2019-12-05 15:38:26

问题


I want to upload doc or docx file using primefaces fileUpload,although I specify the type of file it display Invalid file type

<p:fileUpload cancelLabel="#{contenu.annuler}"
    fileUploadListener="#{utilAdminBean.fileUpload}"
    allowTypes="/(\.|\/)(doc|docx)$/"
    multiple="false" mode="advanced" sizeLimit="52428800"
    showButtons="false" />

回答1:


I found the solution,I forgot to add to the fileupload component inside <h:form nctype="multipart/form-data">

functional code is as follows:

<h:form id="formcontract" enctype="multipart/form-data" dir="rtl">
    <p:fileUpload cancelLabel="#{contenu.annuler}"
        fileUploadListener="#{utilAdminBean.fileUpload}"
        allowTypes="/(\.|\/)(doc|docx|xls|xlsx|pdf)$/"
        multiple="false" mode="advanced" sizeLimit="52428800"
        showButtons="false" />
</h:form>


来源:https://stackoverflow.com/questions/17720985/primefaces-fileupload-invalid-file-type-doc-docx

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