File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Servlets and the fly likes uploading a file to server Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "uploading a file to server" Watch "uploading a file to server" New topic

uploading a file to server

zander alex

Joined: Jun 29, 2013
Posts: 1
Hi All

I am designng a web page using extks and servlets.
The servlet shoud access the clients machine local files and upload to the server.

for example i have a file date.txt in clients local system (C:/users/Documents/date.txt) and it should get upladed into server (/temp/hyd/date.txt).
Any possiblity of doing this other than multipart/form-data.

please help
Tim Cooke

Joined: Mar 28, 2008
Posts: 2534

Imagine the security implications of a browser that allowed a website to go hoking around in the client machine's file system lifting whatever files it wanted? Hence, this is not possible.

There's a pretty good example of how to implement file upload using a web form here:

Tim Driven Development
Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 63858

Also see the ServletsFaq for an entry on file uploading.

[Asking smart questions] [About Bear] [Books by Bear]
Anil Kumar Goud

Joined: Jul 11, 2013
Posts: 12


Find the link for your requirement.
Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 63858

Be aware that emitting HTML from a servlet, as is shown in that example, is considered a bad practice.
I agree. Here's the link:
subject: uploading a file to server
It's not a secret anymore!