Hi,
have You tried running showcase app,
distributed in struts apps.zip or struts all.zip,
there is working example of file upload.

Best greetings,
Pawel Wielgus.

2009/9/25, hisameer <cool_sameer_fo...@yahoo.com>:
>
> I am having trouble with uploading the file using struts 2.1.6. I have to
> upload a picture(.jpg, .bmp,.jpeg,.png,.gif) for one of the business
> requirement. The application server is JBOSS 5.1.The uploaded file is always
> null in my action class:
>
> I followed exactly the same way mentioned in this
> http://struts.apache.org/2.x/docs/file-upload.html link  for the proof of
> concept, Here is my code:
>
> jsp code:
> <%@ taglib prefix="s" uri="/struts-tags" %>
> <s:form action="doUpload" method="post" enctype="multipart/form-data">
>     <s:file name="upload" label="File"/>
>     <s:submit/>
> </s:form>
>
> struts.xml code:
> <constant name="struts.multipart.saveDir"
> value="C:/Temporary_image_location" />
>       <constant name="struts.multipart.maxSize" value="3251468" />
>
> <action name="doUpload" class="com.jctaylor.breg.action.FileUploadAction"
>                       method="uploadFile">
>                       <interceptor-ref name="basicStack" />
>                       <interceptor-ref name="fileUpload">
>                               
> image/jpeg,image/gif,image/png,image/bmp,image.jpg
>                       </interceptor-ref>
>                       <interceptor-ref name="validation" />
>                       <interceptor-ref name="workflow" />
>                       <result
> name="input">/jctaylor/pages/insuranceApplication/fileUploadExample.jsp
>                       </result>
>                       <result
> name="success">/jctaylor/pages/insuranceApplication/fileUploadExample.jsp
>                       </result>
>                       <result
> name="error">/jctaylor/pages/insuranceApplication/fileUploadExample.jsp
>                       </result>
>               </action>
>
> ActionClass code:
> public String uploadFile() throws Exception {
>               System.out.println("In  the file upload file method");
>               File uploadedContent=getUpload();
>               String imageName="C:/test_folder/images/image.jpg";
>               File copyFile=new File(imageName);
>               FileUtils.copyFile(uploadedContent, copyFile);
>                 return SUCCESS;
>            }
> public void setUpload(File file) {
>               this.file = file;
>       }
> public void setUploadContentType(String contentType) {
>               this.contentType = contentType;
>       }
> public void setUploadFileName(String filename) {
>               this.fileName = filename;
>       }
>
> I am trying it since last week and always getting the file as null so it
> means that struts2 upload is not working or there is something wrong the way
> I am doing it.
>
> Please help! I would really appreciate any kind of help in this regard.
>
>
> --
> View this message in context:
> http://www.nabble.com/File-upload-issue-with-Struts-2.1.6-%28uploaded-file-is-always-null-in-action%29-tp25614736p25614736.html
> Sent from the Struts - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
> For additional commands, e-mail: user-h...@struts.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
For additional commands, e-mail: user-h...@struts.apache.org

Reply via email to