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);

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.

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

resizing using height-width in css won't change anything about the size in bytes.
maybe this can help you out.

thank you very much i will try it

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.