aspose 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


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies 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?

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: 39547
    
  27
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 - updated with new look and Ping home screen widget
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?
 
Similar Threads
Upload File Error
Problem in finding pah
refresh onload
Copy file from window machine to Linux machine using Java.io.*
Upload images to apache tomcat server(Linux) from servlet