aspose file tools*
The moose likes Sockets and Internet Protocols and the fly likes Directory Creation on FTP Server using Java Program 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 » Sockets and Internet Protocols
Bookmark "Directory Creation on FTP Server using Java Program" Watch "Directory Creation on FTP Server using Java Program" New topic
Author

Directory Creation on FTP Server using Java Program

Neeteesh Singh
Greenhorn

Joined: Sep 15, 2008
Posts: 9
I want to upload a file on the FTP Server by Selecting a file form my local machine. The Application is designed in an applet where a browse button is clicked to select the file using the FileChooser. After the selection of the file Upload button is clicked to upload the file to the FTP server. But my problem is that it uploads the file in the root path of the FTP server if the directory is not present but it uploads to the correct directory path once I manually create the desired directory. The creation of directory has to be dynamic based on the username and the function the user selects. so it would be very helpful if someone can help me with some java code to first check whether the directory exists and if not then it could create it so that my code can upload the specified file to the specified directory.

Thank You

[ UD: You accidentally posted in all-bold letters with a large font size; I fixed that for you. ]


Neeteesh Singh<br />SCJP 1.4<br />SCWCD 1.4
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 39547
    
  27
That depends on which FTP client library you're using ... ?


Ping & DNS - updated with new look and Ping home screen widget
Neeteesh Singh
Greenhorn

Joined: Sep 15, 2008
Posts: 9
Thank you for the reply...
I have no idea about the FTP libraries. isn't there any other way for achieving what i want to using any java code or program.

Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 39547
    
  27
I thought you had something working already because you said:
it uploads to the correct directory path once I manually create the desired directory.

Not so?

You may want to look into the Apache Commons Net library. It has everything you need to access FTP servers from Java code.
Neeteesh Singh
Greenhorn

Joined: Sep 15, 2008
Posts: 9
i am using the SimpleFTP.jar file for uploading the file to the server.... I want to create a directory dynamically so that i can upload to that folder on the server.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 39547
    
  27
I don't know what library comes in a file called "SimpleFTP.jar"; what does its documentation (particularly the javadocs) say about creating directories? I'm pretty sure it's something all FTP clients support.
Neeteesh Singh
Greenhorn

Joined: Sep 15, 2008
Posts: 9
Thank you for the suggestions... I think I might get what I want from the Apache Commons Net Library.
Mansi Mishra
Ranch Hand

Joined: Dec 26, 2008
Posts: 50
Neeteesh Singh wrote:I want to upload a file on the FTP Server by Selecting a file form my local machine. The Application is designed in an applet where a browse button is clicked to select the file using the FileChooser. After the selection of the file Upload button is clicked to upload the file to the FTP server. But my problem is that it uploads the file in the root path of the FTP server if the directory is not present but it uploads to the correct directory path once I manually create the desired directory. The creation of directory has to be dynamic based on the username and the function the user selects. so it would be very helpful if someone can help me with some java code to first check whether the directory exists and if not then it could create it so that my code can upload the specified file to the specified directory.

Thank You

[ UD: You accidentally posted in all-bold letters with a large font size; I fixed that for you. ]



Hi Neeteesh,

Please have a look at this, might just help your cause...

http://splashtechie.blogspot.com/2007/11/copying-files-from-one-ftp-server-to.html

All the Best
Mansi


http://splashpress.blogspot.com
Neeteesh Singh
Greenhorn

Joined: Sep 15, 2008
Posts: 9
Thank You Mansi for you help....
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Directory Creation on FTP Server using Java Program
 
Similar Threads
oreilly servlet library question
Trying to upload a file through jscape sftp API in java and not able to set the default directory
uploading files in JSP
FTP
FTP via web application