title: Getting File Size - Apache Commons File Upload
body: <p>I am having a webapplication built using Servlet and JSP. I have built a file upload functionality using apache commons library. I would like to restrict the user from uploading a huge file - hence have set the limit as 20 MB. </p>
  
  <p>I am getting the size using <code>Fileitem.getSize()</code> method which I guess is reading the entire file to determine the size. If a user tries to upload a file of few GBs in size , then wouldn't it add a lot of overhead on the application server? Is there any better alternative for getting the file size?</p>