This week's book giveaway is in the OCMJEA forum.
We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line!
See this thread for details.
The moose likes Servlets and the fly likes how to upload a file Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "how to upload a file" Watch "how to upload a file" New topic
Author

how to upload a file

rajareddy annavaarm
Ranch Hand

Joined: Mar 15, 2007
Posts: 96
I need code how to upload a file to server with explanation.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41635
    
  55
There are lots of ways to do that, depending on your circumstances. For starters, have a look at the FileUpload FAQ page.


Ping & DNS - my free Android networking tools app
ankur rathi
Ranch Hand

Joined: Oct 11, 2004
Posts: 3830
Posting again.

One very simple way I came to know recently is through File I/O operations. Yes, this works even if the file is at client machine, just read the file using simple File I/O operation like you do in a desktop application.

Let me know if you face any problem.
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

Originally posted by ankur rathi:
Posting again.

Yes, this works even if the file is at client machine, just read the file using simple File I/O operation like you do in a desktop application.


This most certainly will not work.
How can Java on a server access files on a client machine?
It can't.

rajareddy,
Follow the link in Ulf's post for tips on file uploading.


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
ankur rathi
Ranch Hand

Joined: Oct 11, 2004
Posts: 3830
Originally posted by Ben Souther:


This most certainly will not work.
How can Java on a server access files on a client machine?
It can't.

rajareddy,
Follow the link in Ulf's post for tips on file uploading.


I tested that code and you know what, server and client both were on same machine and it worked.

Hmmm, let me check again. :roll:
ankur rathi
Ranch Hand

Joined: Oct 11, 2004
Posts: 3830
Originally posted by ankur rathi:


I tested that code and you know what, server and client both were on same machine and it worked.

Hmmm, let me check again. :roll:


Very stupid.
Now I am laughing on myself.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: how to upload a file