primefaces fileupload invalid file type doc, docx
Asked Answered
A

1

11

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

enter image description here

<p:fileUpload cancelLabel="#{contenu.annuler}"
    fileUploadListener="#{utilAdminBean.fileUpload}"
    allowTypes="/(\.|\/)(doc|docx)$/"
    multiple="false" mode="advanced" sizeLimit="52428800"
    showButtons="false" />
Aeneous answered 18/7, 2013 at 10:29 Comment(4)
This answer says that allowTypes is a "Semi colon separated list of file extensions to accept". But it seems to depend on which version of Primefaces you use.Caird
It works fine for me using PRIMEFACES 3.5.Lampoon
What is the primefaces version you are using? And also specify JSF Impl.Rammer
you could specify the allowTypeslike this: allowTypes="/(\.|\/)(doc?x)$/" but this is not relevant for this to work. but with 3.5 and 4.0 it works for me.Energy
A
14

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>
Aeneous answered 21/7, 2013 at 13:49 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.