我想使用primefaces fileUpload上传doc或docx文件,虽然我指定了它显示的文件类型 文件类型无效
<p:fileUpload cancelLabel="#{contenu.annuler}"
fileUploadListener="#{utilAdminBean.fileUpload}"
allowTypes="/(\.|\/)(doc|docx)$/"
multiple="false" mode="advanced" sizeLimit="52428800"
showButtons="false" />
答案 0 :(得分:13)
我找到了解决方案,我忘了添加到<h:form nctype="multipart/form-data">
功能代码如下:
<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>