This week's book giveaways are in the Cloud and AI/ML forums.
We're giving away four copies each of Cloud Native Patterns and Natural Language Processing and have the authors on-line!
See this thread and this one for details.
Win a copy of Cloud Native PatternsE this week in the Cloud forum
or Natural Language Processing in the AI/ML forum!
  • 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
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Knute Snortum
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Ron McLeod
  • Piet Souris
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Frits Walraven
  • Ganesh Patekar

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: 43011
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: 43011
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: 43011
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....
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!