I believe the documentation is incorrect on the web.  The setUpload doesn't
take a File object, it takes a String that is the fully qualified path to
the temporary file created by the internal upload support of struts.  So
what you actually need is:

   public void setUpload(String upload)
   {
       this.upload = new File(upload);
   }

(*Chris*)

On Fri, Sep 4, 2009 at 11:40 AM, Bill Bohnenberger <bill98...@gmail.com>wrote:

> Ok, I'm sure I must be doing something dumb here, but I can't seem to find
> it. I'm have a problem uploading a simple text file... when I try to a file
> named "test.txt", I get an action error message "File upload error: invalid
> data." and all my file variables (see below) are null when the action
> method
> gets called.
>
> Here's my setup:
>
> Config:
>
>    <action name="BulkUpload_*" class="com.rp.db.actions.BulkUpload"
> method="{1}">
>        <interceptor-ref name="basicStack"/>
>        <interceptor-ref name="fileUpload">
>            <param name="maximumSize">8192000</param>
>            <param
> name="allowedTypes">image/jpeg,image/gif,text/plain</param>
>        </interceptor-ref>
>        <interceptor-ref name="validation"/>
>        <interceptor-ref name="workflow"/>
>
>        <result name="input">bulkUpload.jsp</result>
>        <result name="done" type="redirect">Menu_init</result>
>        <result name="login" type="redirect">Login_init</result>
>    </action>
>
> Relevant jsp code:
>
> <s:form action="BulkUpload_doCommand" method="post"
> enctype="multipart/form-data">
>    <s:file label="Bulk File" name="upload" size="45"/>
>    <s:submit name="command" value="Upload File"/>
>    <s:submit name="command" value="Cancel"/>
> </s:form>
>
> Action excerpts:
> ...
>    private String uploadContentType;
>    private String uploadFileName;
>    private File upload;
> ...
>    public void setUpload(File upload)
>    {
>        this.upload = upload;
>    }
>    public void setUploadFileName(String uploadFileName)
>    {
>        this.uploadFileName = uploadFileName;
>    }
>    public void setUploadContentType(String uploadContentType)
>    {
>        this.uploadContentType = uploadContentType;
>    }
>
> As I mentioned above, when I use this form to upload a text file named
> "test.txt" I get the action error message "File upload error: invalid
> data."
> and all my "upload..." variables are null.
>
> Thanks,
> Bill
>

Reply via email to