aspose file tools*
The moose likes Struts and the fly likes struts 2 file upload problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "struts 2 file upload problem" Watch "struts 2 file upload problem" New topic
Author

struts 2 file upload problem

vik ar
Ranch Hand

Joined: Jul 31, 2009
Posts: 104
Hi. I have the following code:


Now when I attempt to upload a image file (1.jpg) it uploads fine in firefox, but in ie7 I get an error saying content type is not allowed?
Ankit Garg
Sheriff

Joined: Aug 03, 2008
Posts: 9303
    
  17

The reason that I can think of is that IE is not setting the content type of the uploaded file properly. Try to map jpg files to image/jpeg content type using the <mime-mapping> tag of the web.xml. It might work then...


SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

You could also check what the actual mimetype is--might it be "image/jpg"?
galne vaibhav
Greenhorn

Joined: Nov 30, 2009
Posts: 9
you are making mistake you mention alloewed type as image/jpeg and trying to upload image/jpg

just open the file in paint save as .jpeg format and try to upload
Ankit Garg
Sheriff

Joined: Aug 03, 2008
Posts: 9303
    
  17

Galne as I said here, don't put whatever you say in [quote] [/quote] tags. It looks as if you've just quoted what someone else has said and not written anything of your own...
vik ar
Ranch Hand

Joined: Jul 31, 2009
Posts: 104
Hi I have put the following in web.xml. Still no luck
Ankit Garg
Sheriff

Joined: Aug 03, 2008
Posts: 9303
    
  17

Vik, can you upload .jpeg files from IE (as galne said)?? Also can you show us the code i.e. the JSP page where the file upload control is...
vik ar
Ranch Hand

Joined: Jul 31, 2009
Posts: 104
Sorry I just checked in windows explorer details view and it specifies the file is of type JPEG Image. The following is the jsp
 
jQuery in Action, 2nd edition
 
subject: struts 2 file upload problem