struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Struts Two <struts...@yahoo.ca>
Subject Re: Struts2 upload
Date Sun, 02 Nov 2008 18:13:16 GMT
I had a similar problem and it used to happen whenever the file uploaded had a size larget
than the one specified in struts configuration. Try files of small size first to see if you
face the same issue (though your problem may be totally different).
 
 
----- Original Message ----
From: Nick J <nick.jerram@gmail.com>
To: user@struts.apache.org
Sent: Saturday, November 1, 2008 5:54:57 PM
Subject: Struts2 upload


Hi, I am having some trouble with Uploads in Struts 2.
Here is the action:
<package name="uploads" extends="json-default" namespace="/_uploads">
<!-- ...other actions ...-->
        <action name="imageUpload" class="uploadManager" method="imageUpload">
            <interceptor-ref name="fileUpload"/>
            <result>/upload.html</result>
        </action>
</package>

Here is the HTML form:
<form name="myForm" action="/_uploads/imageUpload"
enctype="multipart/form-data">
    <input type="file" name="imageUpload" value="Browse ..." />
    <input type="submit" />
</form>

Here's the appropriate part of the action class:

    public String imageUpload() {
        return ActionSupport.SUCCESS;
    }
    
    public List<Image> getImageList() {
        return images;
    }
    
    public void setImageUpload(File myImage) {
        uploadedImage = myImage;
    }
    
    public void setImageUploadContentType(String contentType) {
        imageContentType = contentType;
    }
    
    public void setImageUploadFileName(String filename) {
        imageFilename = filename;
    }

I have debugger break-points in the  imageUpload method, and in the setter
methods. 
The execution never reaches the setters, and when it breaks in the
imageUpload method,
and I inspect the values of uploadedImage, imageContentType and
imageFilename they are all null, so the interceptor has not called the the
setters like I was expecting it to. As far as I can tell, this agrees with
all the tutorials I've read, so I'm at a loss now.. If anyone has any ideas,
I'd be very greatful!

thanks!



-- 
View this message in context: http://www.nabble.com/Struts2-upload-tp20284756p20284756.html
Sent from the Struts - User mailing list archive at Nabble.com.


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


      __________________________________________________________________
Ask a question on any topic and get answers from real people. Go to Yahoo! Answers and share
what you know at http://ca.answers.yahoo.com


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


Mime
View raw message