You can find the full source code for this website in the Seam package in the directory /examples/wiki. It is licensed under the LGPL.
Excuse me, could perform what you Wait? If so, you could put your SOLUTION, PLEASE? Is that I am having the same problem
Thank you
This work for me
@Name("uploadHandler") @Scope(ScopeType.EVENT) public class UploadHandler { @In(value="#{facesContext}") FacesContext facesContext; @Logger private Log log; private byte[] file; public void handleUpload() throws IOException{ String path = ((ServletContext) facesContext.getExternalContext().getContext()).getRealPath("/my/files/dir"); File f = new File(path,"myFile.txt"); log.info(f); FileOutputStream fo = new FileOutputStream(f); fo.write(file); fo.flush(); fo.close(); } public byte[] getFile() { return file; } public void setFile(byte[] file) { this.file = file; } }
and the form
<h:form id="fooForm" enctype="multipart/form-data"> <s:fileUpload id="file" data="#{uploadHandler.file}" accept="image/jpg" /> <h:commandButton id="upload" value="Upload !!" action="#{uploadHandler.handleUpload}"/> </h:form>
But I don't recommand to use the ....getRealPath(/my/files/dir);.... instead use a path that you configure in seam.properties.
/my/files/dir
Excuse me, could perform what you Wait? If so, you could put your SOLUTION, PLEASE? Is that I am having the same problem
Thank you
This work for me
@Name("uploadHandler") @Scope(ScopeType.EVENT) public class UploadHandler { @In(value="#{facesContext}") FacesContext facesContext; @Logger private Log log; private byte[] file; public void handleUpload() throws IOException{ String path = ((ServletContext) facesContext.getExternalContext().getContext()).getRealPath("/my/files/dir"); File f = new File(path,"myFile.txt"); log.info(f); FileOutputStream fo = new FileOutputStream(f); fo.write(file); fo.flush(); fo.close(); } public byte[] getFile() { return file; } public void setFile(byte[] file) { this.file = file; } }and the form
<h:form id="fooForm" enctype="multipart/form-data"> <s:fileUpload id="file" data="#{uploadHandler.file}" accept="image/jpg" /> <h:commandButton id="upload" value="Upload !!" action="#{uploadHandler.handleUpload}"/> </h:form>But I don't recommand to use the ....getRealPath();.... instead use a path that you configure in seam.properties.