Param-Ganak
Param-Ganak

Reputation: 5875

How to upload file from local client machine to FTP using JSP and servlet? How to give url address of the file on FTP in html to view them in browser?

I want to develop a file upload utility using JSP and servlet. In this a user can upload any file, size ranging from few MB's to few hundred MB's. This utility contains a regular form designed using html in a jsp file. when this form is submitted the selected file on given local client machine path is get uploaded with the help of called servlet.

The twist is here I want to upload my files directly from client local machine to FTP server. This FTP server may be on different machine or may be on same machine where my web server and db server is situated.

I searched on internet for guidance but I found the code which uploads files from local client machine to webserver. Or from webserver local path to FTP server. I dint found such tutorial which uploads files from local client machine to directly FTP server. I want to ask expert is there any way to achive above goal i.e. uploading file from client machine to FTP server directly using jsp servlet.

I need some or complete reference code for the same.

I have another question in which user will see the list of uploaded file names in hyper link form. I can do this part. When user clicks on these hyperlink he can see the file in different browser window. But the twist is the showed file will come from above FTP. So the question is how to give the url of file on FTP in the above hyperlink. Because to access the file from FTP we need to give its host address, username, password and port number. How to achive this task.

Friends please guide me in these issues

Thanks You!

Upvotes: 0

Views: 5117

Answers (2)

Thiago Custodio
Thiago Custodio

Reputation: 18387

You can do an adapter on your server code. Instead of save the file to a directory or db, upload it to your ftp. Here's a sample:

Upload to FTP Sample

Upvotes: 1

f_puras
f_puras

Reputation: 2505

Typical browsers can perform FTP downloading, but not uploading. Thus you will need to run code in the browser, as a Java Applet, Flash component, Silverlight control or whatever.

Thus, HTTP uploading has some advantages, see HTTP vs FTP upload.

Upvotes: 1

Related Questions