Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
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
Author

uploading a file to server

zander alex
Greenhorn

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
thanks
Tim Cooke
Bartender

Joined: Mar 28, 2008
Posts: 849
    
  42

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: http://www.coderanch.com/t/609232/Servlets/java/find-uploaded-file-upload


Tim Driven Development
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60802
    
  65

Also see the ServletsFaq for an entry on file uploading.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Anil Kumar Goud
Greenhorn

Joined: Jul 11, 2013
Posts: 12

Hey,

Find the link for your requirement. http://www.tutorialspoint.com/servlets/servlets-file-uploading.htm
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60802
    
  65

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 ?