File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Servlets and the fly likes How can validate input field file . Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "How can validate input field file ." Watch "How can validate input field file ." New topic

How can validate input field file .

Chhaya Dhanani
Ranch Hand

Joined: Apr 11, 2001
Posts: 70
hi all,
i ave been raking my head over this problem and don't seem to find a way.
I am using com.oreilly.servlet.MultipartRequest to upload files form a html page through file input type.
This allows me to type any non existent file name.
and then i genrate i jsp page which shows file upload succesful message.
How can i check where this file is a existent file ( i dont think i can check on the hard idsk from where it was uploaded..)
also how i can validate for the size of the file and show error message if this file is empty file.
please let me know client side javascript validations as well as server side validations..
Thanx in advance..
a real quick reply will be highly appreciated.!!

Raj Mohan
Ranch Hand

Joined: Sep 26, 2000
Posts: 73
one way is, once you upload any file, this creates a file at server with file size 0. You have the filename at the serverside. Now check the file size of this filename at server side where it is being saving. if it is 0, then the file is not saved properly.
Chhaya Dhanani
Ranch Hand

Joined: Apr 11, 2001
Posts: 70
Thanx Raj.
That was the initial solution that me had thought of.
I agree. Here's the link:
subject: How can validate input field file .
Similar Threads
Need help in Validations
Need help in Validations
Regarding struts validation
Handling error messages (Struts2 jquery )
upload file question