Here are my codes:
index.xhtml
Code: Select all
<h:form>
<p:growl id="messages" showDetail="true"/>
<p:fileUpload allowTypes="*.jpg;" fileUploadListener="#{uploadbean.handleFileUpload}" label="Resim Yükle"/>
</h:form>
Code: Select all
@Named
@RequestScoped
public class uploadbean {
public void handleFileUpload(FileUploadEvent fEvent) {
System.out.print("heyyyyyyyyyyyyy");
System.out.print(fEvent.getFile().getFileName().toString());
FacesMessage msg = new FacesMessage("Succesful", fEvent.getFile().getFileName() + " is uploaded.");
FacesContext.getCurrentInstance().addMessage(null, msg);
}
}
Waiting for your helps.
Bilal