Note that there are some explanatory texts on larger screens.

plurals
  1. POPrimeFaces Upload file not uploading
    primarykey
    data
    text
    <p>I am using PrimeFaces 3 and trying to upload a file but when I debug the file is always null. Below you can see my code. Can anyone spot what is the issue?</p> <pre><code>&lt;h:form enctype="multipart/form-data"&gt; &lt;p:fileUpload value="#{uploadFileMB.file}" mode="simple" /&gt; &lt;p:commandButton value="Submit" ajax="false" action="#{uploadFileMB.submit()}"/&gt; &lt;h:outputLabel value="#{uploadFileMB.text}" /&gt; &lt;/h:form&gt; import javax.enterprise.context.SessionScoped; import javax.faces.bean.ManagedBean; import javax.faces.bean.RequestScoped; import org.primefaces.model.UploadedFile; @ManagedBean @SessionScoped public class UploadFileMB { UploadedFile file; String text; public String getText() { return text; } public void setText(String text) { this.text = text; } public UploadedFile getFile() { return file; } public void setFile(UploadedFile file) { this.file = file; } public void submit(){ System.out.println("Trial "+file); UploadedFile a=file; if(file==null) text="not uploaded"; else text=file.getFileName()+" uploaded"; } /** Creates a new instance of UploadFileMB */ public UploadFileMB() { } } &lt;filter&gt; &lt;filter-name&gt;PrimeFaces FileUpload Filter&lt;/filter-name&gt; &lt;filter-class&gt;org.primefaces.webapp.filter.FileUploadFilter&lt;/filter-class&gt; &lt;/filter&gt; &lt;filter-mapping&gt; &lt;filter-name&gt;PrimeFaces FileUpload Filter&lt;/filter-name&gt; &lt;servlet-name&gt;Faces Servlet&lt;/servlet-name&gt; &lt;/filter-mapping&gt; </code></pre> <p>And the filter in both web.xml and faces.config I have tried a number of suggestions and debugged it many times but I can't figure it out.</p> <p>This is my faces-config:</p> <pre><code>&lt;?xml version='1.0' encoding='UTF-8'?&gt; &lt;!-- =========== FULL CONFIGURATION FILE ================================== --&gt; &lt;faces-config version="2.0" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_2_0.xsd" &gt; &lt;dependency&gt; &lt;groupId&gt;commons-fileupload&lt;/groupId&gt; &lt;artifactId&gt; commons-fileupload&lt;/artifactId&gt; &lt;version&gt;1.2.2&lt;/version&gt; &lt;/dependency&gt; &lt;dependency&gt; &lt;groupId&gt;commons-io&lt;/groupId&gt; &lt;artifactId&gt; commons-io&lt;/artifactId&gt; &lt;version&gt;2.1&lt;/version&gt; &lt;/dependency&gt; &lt;lifecycle&gt; &lt;phase-listener&gt;security.SecurityFilter&lt;/phase-listener&gt; &lt;/lifecycle&gt; &lt;filter&gt; &lt;filter-name&gt;PrimeFaces FileUpload Filter&lt;/filter-name&gt; &lt;filter-class&gt;org.primefaces.webapp.filter.FileUploadFilter&lt;/filter-class&gt; &lt;init-param&gt; &lt;param-name&gt;uploadDirectory&lt;/param-name&gt; &lt;param-value&gt;C:/home/vanessa/Desktop&lt;/param-value&gt; &lt;/init-param&gt; &lt;/filter&gt; &lt;filter-mapping&gt; &lt;filter-name&gt;PrimeFaces FileUpload Filter&lt;/filter-name&gt; &lt;servlet-name&gt;Faces Servlet&lt;/servlet-name&gt; &lt;/filter-mapping&gt; &lt;/faces-config&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload