File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Java in General and the fly likes Uploading and using a file from a web page Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Uploading and using a file from a web page" Watch "Uploading and using a file from a web page" New topic

Uploading and using a file from a web page

Tomas Nilson
Ranch Hand

Joined: Jan 14, 2002
Posts: 33
I have a web page where I want users to be able to select a file from their harddrive and then upload it to my web server where my Java Bean will parse the spread sheet using POI.
I have already solved the last bit (I have made an application which parses a document from the HD), but how do I upload the file? How do I pass it on to the bean?
Thanks a lot!!
Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 63870

To upload a file you need to use a multi-part form and the "file" input element to create the upload controls on your web page.
Then, write a servlet to post this form to that can parse the resulting multi-part request. The servlet can create an instance of your bean and pass the file data to it.
Search these forums for terms like "file upload", "multipart form" and "smart upload" to find lots of topics that discuss this very issue.
P.S. Further questions on this topic might be better suited to the servlets forum.

[Asking smart questions] [About Bear] [Books by Bear]
Toseef Alam

Joined: Aug 15, 2003
Posts: 2
I want to upload a file from one server to another server. I have a local server where i have a web based application. I want to upload a zip file from this local server to remote server and user doesn't know about that file. User only click a upload button and local server should read that file and submit a rewuest with this file to the remote server.
Please, somebody help me for this. If anybody have any other way to do write me that also.

Maulin Vasavada
Ranch Hand

Joined: Nov 04, 2001
Posts: 1873
it seems u need ftp rather than multi-part request here as u don't want user to see anything.
i guess u can look for 3rd party ftp clients in java on google.
I agree. Here's the link:
subject: Uploading and using a file from a web page
It's not a secret anymore!