Meaningless Drivel is fun!
The moose likes Servlets and the fly likes Upload file from browser Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Upload file from browser" Watch "Upload file from browser" New topic

Upload file from browser

jack nick
Ranch Hand

Joined: Jan 11, 2001
Posts: 96
Hi there,
I have to upload files from a browser (local system) to a location on the web server. Am using JSP to do this. Am totally clueless on how to go about doing. Some tips would help a lot.
hemanth kumar
Ranch Hand

Joined: Mar 15, 2001
Posts: 55
Hi Jack
There are several options that u can follow
Code the Uploading part urself or take a ready made components
Some of the readymade ones that i know are
If u want to code it urself then here are some steps to follow
U should use the <FILE> tag for choosing the file on ur page.
Also the form tag should have ENCTYPE as multipart/form-data
Heres a sample
'<form id="frmUpload" name="frmUpload" METHOD="post" ENCTYPE="multipart/form-data">'
Now when u click on the upload button in ur page,the file that is to be uploaded goes as Header data to the submitted page.
In the submitted page code has to be written to read the header data and pluck out the File data from there and recreate the uploaded file in the server.
There is a very nice explanation on how the Uploading process actually works given in Read that for a much clearer understanding.
Hope this helps
jack nick
Ranch Hand

Joined: Jan 11, 2001
Posts: 96
Thanks Hemanth,
Will check this out
Andrew Shafer
Ranch Hand

Joined: Jan 19, 2001
Posts: 338

A package that can be used to upload files and so much more:

available from
Free for use in non-comercial projects and free for use in commercial projects if you buy the guy's book.
(read the license)

I agree. Here's the link:
subject: Upload file from browser
jQuery in Action, 3rd edition