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. ]
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: 35426
9
posted
0
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
posted
0
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: 35426
9
posted
0
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
posted
0
Thank you for the suggestions... I think I might get what I want from the Apache Commons Net Library.
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...