File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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
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?

Joseph Bashir
Ranch Hand

Joined: Jun 16, 2004
Posts: 41
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
Marshal

Joined: Mar 22, 2005
Posts: 41830
    
  63
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


Ping & DNS - my free Android networking tools app
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

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.


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to upload a file?