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