• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Directory Creation on FTP Server using Java Program

 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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. ]
 
Rancher
Posts: 43016
76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That depends on which FTP client library you're using ... ?
 
Neeteesh Singh
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Rancher
Posts: 43016
76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Rancher
Posts: 43016
76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you for the suggestions... I think I might get what I want from the Apache Commons Net Library.
 
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
 
Neeteesh Singh
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank You Mansi for you help....
 
    Bookmark Topic Watch Topic
  • New Topic