File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Servlets and the fly likes Urgent: Need to know the size of Image Uploaded Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Urgent: Need to know the size of Image Uploaded" Watch "Urgent: Need to know the size of Image Uploaded" New topic
Author

Urgent: Need to know the size of Image Uploaded

daman sidhu
Ranch Hand

Joined: Aug 19, 2000
Posts: 184
Hi Guys,
I have an application where i upload a image through a web page to the server and put it in the database, i need to check that the image is of particualr height and width only and then only insert in the DB else show error. I tried it by converting the bytes as below but got -1 as height and width.
This coding is in the servlet class:
// f is the file object uploaded.
byte [] b=new byte[(int)f.length()];
fis.read(b);
System.out.println("after file read");
// this is the code to check the file length
Toolkit toolKit=Toolkit.getDefaultToolkit();
Image image=toolKit.createImage(b);
int width=image.getWidth(null);
int heigth=image.getHeight(null);
System.out.println("Height is "+heigth+" Width is "+width);
***************
I get both as -1
I will be very thankful if anyone can help me out in this.
Regards,
Daman

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Urgent: Need to know the size of Image Uploaded