Hi everybody, I am Chaitanya, I am working on a web application, on of the requirement is to upload files to the server. Say a mp3 song. The user has to upload only files less than or equal to 5MB. I can't do this at the client side. This is done at server side using a servlet.
If the user tries to upload a file say 500MB, the request takes so much time. The entire file must be sent to server, then the servlet must check the file size and take a decision.
But in gmail we have a good approach, the page will not be redirected, but the file will be uploaded, I think its AJAX, I don't know exactly.
But here I see a small problem in gmail. Suppose I have selected the files to be uploaded, then while I am writing the mail, what if the power has cut? So the files will be on the server for no use. How to handle such things?
Firstly, have you looked at Apache's file upload library? Maintaining state during a large file transfer is certainly non-trivial, if you were to roll your own you'd have to store state on the client and/or server to determine how far through a file you were, not many HTTP based file uploaders do this.