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

problem in image File format

kalai rathi
Greenhorn

Joined: Aug 16, 2011
Posts: 2
Hello,
I am new to Spring MVC

I am uploading image into DataBase. Before uploading the image,validate the image file format .
The file format should be (*.png,*.jpeg,*.jpg,*.gif) ,for other types must show error. this is the logic.

this is my jsp
<form:form commandName="event" id="eventForm" name="eventForm" method="post" enctype="multipart/form-data">

<label>Event Photo</label>
<input type="file" name="eventPhoto"/>
<form:errors path="eventPhoto" cssClass="error" />
</form>

My validation here.

if((!eventForm.getEventPhoto().getContentType().equals("image/png"))&&
(!eventForm.getEventPhoto().getContentType().equals("image/x-png"))&&
(!eventForm.getEventPhoto().getContentType().equals("image/jpeg"))&&
(!eventForm.getEventPhoto().getContentType().equals("image/pjpeg"))&&
(!eventForm.getEventPhoto().getContentType().equals("image/jpg"))&&
(!eventForm.getEventPhoto().getContentType().equals("image/gif")))
{
errors.rejectValue("eventPhoto", "filetype.required");
}

the above code has worked in Safari, Firefox, Chrome. Except IE


when i upload *.bmp image in IE it accepts as --- image/pjpeg
.ico--------image/x-icon

it doesn't show error. IE accepts all image formats. This is the problem.

problem 2)

validate the image dimension ( height & weight) like 400*400

Thanks
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: problem in image File format