Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
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

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
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: 849

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: 60802

Also see the ServletsFaq for an entry on file uploading.

[Asking smart questions] [Bear's FrontMan] [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: 60802

Be aware that emitting HTML from a servlet, as is shown in that example, is considered a bad practice.
subject: uploading a file to server
Similar Threads
Uploading File??
Writing to web space from Java applet.
Upload files from Swing Desktop Client to server
Uploading Files from Client to Network Directories
Why fast upload and slow downloads ?