Thanks Dave for reply..
I have no clue what is happening...I can see below statement in log..

Content-Type not allowed: myPhoto
"upload_460c03b6_115a6ef087d__8000_00000000.tmp" image/jpeg

I have configured filters like below in web.xml.. I don't have context
clean-up filter. Where should I place this filter?

<filter>
        <filter-name>openSessionInViewFilter</filter-name>
        <filter-class>
org.springframework.orm.hibernate3.support.OpenSessionInViewFilter
</filter-class>
    </filter>

    <filter>
        <filter-name>filterDispatcher</filter-name>
        <filter-class>org.apache.struts2.dispatcher.FilterDispatcher
</filter-class>
    </filter>

    <filter-mapping>
        <filter-name>openSessionInViewFilter</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>

    <filter-mapping>
        <filter-name>filterDispatcher</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>

    <listener>
        <listener-class>
org.springframework.web.context.ContextLoaderListener</listener-class>
    </listener>

    <listener>
        <listener-class>org.apache.struts2.tiles.StrutsTilesListener
</listener-class>
    </listener>

Thanks
Raghu



On 10/15/07, Dave Newton <[EMAIL PROTECTED]> wrote:
>
> In general it's a good idea to include things like
> what is actually happening: what symptoms (besides
> "the file isn't uploading" :) are there? Is there
> anything in the logs?
>
> Are you including the context cleanup filter in your
> web.xml?
>
> d.
>
> --- Raghuveer Rawat <[EMAIL PROTECTED]> wrote:
>
> > Hi, I am trying to upload a jpg image using Struts2
> > but no luck till now. It
> > will be great if someone could help me in moving
> > further.
> >
> > I am using Struts 2.0.8 and i have
> > commons-fileupload-1.2.jar and
> > commons-io-1.3.2.jar in classpath
> >
> > My code looks like below.
> >
> > MyPhoto.jsp
> >
> > <s:form method="post" action="myPhotoUpload"
> > enctype="multipart/form-data">
> > <s:file name="myPhoto" cssClass="textbox1"
> > accept="image/*" />
> > <s:submit name="method:upload" cssClass="btn"
> > value="Upload" />
> > </s:form>
> >
> > Action class: MyPhotoUploadAction.java
> >
> > private File myPhoto;//The actual file
> >     private String myPhotoContentType; //The content
> > type of the file
> >     private String myPhotoFileName; //The uploaded
> > file name
> >
> >  public File getMyPhoto() {
> >         return myPhoto;
> >       }
> >
> >       public void setMyPhoto(File myPhoto) {
> >         System.out.println("Inside setMyPhoto");
> >         this.myPhoto = myPhoto;
> >       }
> >
> >       public String getMyPhotoContentType() {
> >         return myPhotoContentType;
> >       }
> >
> >       public void setMyPhotoContentType(String
> > myPhotoContentType) {
> >         System.out.println("Inside
> > setMyPhotoContentType");
> >         this.myPhotoContentType =
> > myPhotoContentType;
> >       }
> >
> >       public String getMyPhotoFileName() {
> >           System.out.println("Inside
> > getMyPhotoFileName:"+myPhotoFileName);
> >         return myPhotoFileName;
> >       }
> >
> >       public void setMyPhotoFileName(String
> > myPhotoFileName) {
> >         System.out.println("Inside
> > setMyPhotoFileName:"+myPhotoFileName);
> >         this.myPhotoFileName = myPhotoFileName;
> >       }
> >
> >       public String upload() {
> >          try{
> >             System.out.println("Inside Upload");
> >             File destDir = new
> > File("images/member");
> >              System.out.println("File
> > Name:"+this.getMyPhotoFileName());
> >              System.out.println("File
> > ContentType:"+this.getMyPhotoContentType());
> >
> > FileUtils.copyFileToDirectory(getMyPhoto(),
> > destDir);
> >              return SUCCESS; // redirect to welcome
> > page.
> >          }catch(Exception exp){
> >              LOG.error("File Upload Error:"+ exp);
> >              this.addActionError("File Upload
> > Error:"+ exp);
> >              return ERROR;
> >          }
> >       }
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>

Reply via email to