0

Hello
I have a site. For not i just check the size of the image and if it is bigger than a size i just do not upload it. Is there a way to reduce the size and upload it later?
Thank you

DiskFileUpload fu = new DiskFileUpload();
 FileItem fi4=null;
try{
   fileItems=fu.parseRequest(request);
}
catch (Exception e){
   System.err.println("Error here-------------------");
}
 try{
   //getting the parameter
  itr=fileItems.iterator();
}catch (Exception e){
   System.err.println("There is an error here-------------------");
}
fi4=(FileItem)itr.next();
//taking the filename
String filename=fi4.getName();
//taking the filesize
long filesize=fi4.getSize();
String thepath="images/restaurant";
if (filesize>maxsize){
     //i want to resize the image here to be at the correct maxfilesize
}
File fNew= new File(request.getRealPath(thepath), filename);
System.err.println("Got thereeeee");
fi4.write(fNew);

Edited by xxmp

2
Contributors
4
Replies
23
Views
4 Years
Discussion Span
Last Post by xxmp
0

do you mean the size as in number of pixels, or as in number of bytes?
yes, you can either check the size, or re-size if you want it smaller.

0

i want to edit the size of the bytes is there a library that i can use to do this? Is not good to set the size of the image with css? it will be better to resize iton upload?
Thank you very much

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.