Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to upload a file?

 
Joseph Bashir
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My website is running on Linux. I want to upload images using java code. Can someone please help me how can I do it? If someone can give me code, I will be thankful to him.

Specially I would like to know:
I have Windows 2000. When I browse the file to upload how does the Linux will read file from this windows path, say D:\images\myimages.jpg and how this image will be uploaded to some folder in my site that's on linux?

Thanks
[ December 14, 2007: Message edited by: Joseph Bashir ]
 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can use the Commons HttpClient library on the client, and the Commons FileUpload library in a servlet on the server. An article that describes how to use both is linked in http://faq.javaranch.com/java/FileUpload
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Joseph Bashir:

I have Windows 2000. When I browse the file to upload how does the Linux will read file from this windows path, say D:\images\myimages.jpg and how this image will be uploaded to some folder in my site that's on linux?
[/QB]


Linux doesn't read the file system on your client machine.
Your browser does.

The browser will send the file to the server.
Whatever upload library you use will have a way for you to configure the location for uploaded files. The path information sent with the file (from some browsers) won't affect where the file ends up on your server.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic