This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes Servlets and the fly likes upload limit Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "upload limit" Watch "upload limit" New topic

upload limit

Fernando Dominguez
Ranch Hand

Joined: Sep 01, 2006
Posts: 102


Recently I have made a servlet to upload files to my aplication.
I needed to define the maximun size to upload.

The problem is that the size of the file is not checked until the file is fully uploaded.

Now, I'm using apache.commons.fileupload

Is there any way to check the size when the file is uploading?

Thanks in advance.
Jeanne Boyarsky
internet detective

Joined: May 26, 2003
Posts: 30356

I haven't tried this, so it's more of speculation than an answer.

There is a streaming API in commons. If you were reading the stream, you could track how much is uploaded. You wouldn't be able to give the user a nice message as you'd have to just stop uploading at that point. But you could counter that with AJAX to state the server gave up.

[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
It is sorta covered in the JavaRanch Style Guide.
subject: upload limit