Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa Ajax upload files to apache ftp server

Have Programming Question? Ask it here!
 
 
 


tin linn soe
upload files to apache ftp server
3 Answer(s)      5 years and 8 months ago
Posted in : Ajax



Advertisement
View Answers

December 29, 2008 at 1:53 AM


Hi Friends

i can't understand your actual problem send me details about your Application.....


import java.io.*;
import org.apache.commons.net.ftp.*;

public class FTPServerConnect {
public FTPServerConnect(){}

public static void main(String args[]) {
try {
String ftpHost = "localhost";
String ftpUserName = "admin";
String ftpPassword = "admin";
//String ftpHost = "192.168.0.144";
//String ftpUserName = "rootadmin";
//String ftpPassword = "rootadmin";
String ftpRemoteDirectory = "/Ah Kyi Ta Chat";
String fileToTransmit = "C:\\my.ini";

FTPClient ftp = new FTPClient();
int reply;

ftp.connect(ftpHost);
reply = ftp.getReplyCode();
System.out.println("Reply:"+reply);
System.out.println("FTP Reply:"+FTPReply.isPositiveCompletion(reply));

if(!FTPReply.isPositiveCompletion(reply)) {
try {
ftp.disconnect();
} catch (Exception e) {
System.err.println("Unable to disconnect from FTP server " + "after server refused connection. "+e.toString());
} throw new Exception ("FTP server refused connection.");
}
System.out.println("Connected to " + ftpHost + ". "+ftp.getReplyString());

System.out.println("User Name:"+ftpUserName+",Password:"+ftpPassword);
if (!ftp.login(ftpUserName, ftpPassword)) {
throw new Exception ("Unable to login to FTP server " + "using username "+ftpUserName+" " + "and password "+ftpPassword);
}
System.out.println(ftp.getReplyString());
System.out.println("Login Successful.");
System.out.println("Remote system is " + ftp.getSystemName());

------------------------------------------


December 29, 2008 at 1:54 AM


ftp.setFileType(FTP.BINARY_FILE_TYPE);

if (ftpRemoteDirectory != null && ftpRemoteDirectory.trim().length() > 0) {
System.out.println("Changing to FTP remote dir: " + ftpRemoteDirectory);
ftp.changeWorkingDirectory(ftpRemoteDirectory);
reply = ftp.getReplyCode();
System.out.println("Change dir Okay:");
System.out.println("Reply Code:"+reply);
if(!FTPReply.isPositiveCompletion(reply)) {
throw new Exception ("Unable to change working 5 " + "to:"+ftpRemoteDirectory);
}
}

System.out.println("File Directory:"+fileToTransmit);
File f = new File(fileToTransmit);
System.out.println("Storing file as remote filename: " + f.getName());
boolean retValue = ftp.storeFile(f.getName(), new FileInputStream(f));
if (!retValue) {
throw new Exception ("Storing of remote file failed. ftp.storeFile()" + " returned false.");
}
System.out.println("File uploaded successful.");

/* String fileNames[]=ftp.listNames();
for(int i=0;i<fileNames.length;i++){
System.out.println("Files names:"+fileNames[i]);
}*/
FTPFile files[] = ftp.listFiles();
reply = ftp.getReplyCode();
System.out.println("File length:"+files.length);
if(!FTPReply.isPositiveCompletion(reply)) {
throw new Exception ("Unable to get list of files to dowload.");
}

if (files.length == 0) {
System.out.println("No files are available for download.");
} else {
for (int i=0; i<files.length; i++) {
System.out.println("Downloading file "+files[i].getName()+" Size:"+files[i].getSize());
String outputFileName = "c:\\temp\\"+files[i].getName();
f = new File(outputFileName);
retValue = ftp.retrieveFile(files[i].getName(), new FileOutputStream(f));
if (!retValue) {
throw new Exception ("Downloading of remote file "+files[i].getName()+" failed. ftp.retrieveFile() returned false.");
}

/*
retValue = ftp.deleteFile(files[i].getName());
if (!retValue) {
log.error ("Unable to delete remote file "+files[i].getName()+". ftp.deleteFile() returned false.");
}
*/
}
}

try {
//ftp.logout();
ftp.disconnect();
} catch (Exception exc) {
System.err.println("Unable to disconnect from FTP server. " + exc.toString());
}
} catch (Exception e) {
System.err.println("Error: "+e.toString());
}
System.out.println("Process Complete.");
System.exit(0);
}
}

Thanks


March 8, 2012 at 12:27 PM


where is FTPClient() coding??? AND WHT TO CODE ON IT??



Related Tutorials/Questions & Answers:
files upload to apache ftp server - Ajax
files upload to apache ftp server  Please, how to upload multiple files to apache ftp server using ajax . I want to upload files using drag drop... line. but I am trying to upload files using ajax. I want you to answer to me
files upload to apache ftp server - Ajax
files upload to apache ftp server  Please, how to upload multiple files to apache ftp server using ajax . I want to upload files using drag drop... line. but I am trying to upload files using ajax. I want you to answer to me
Advertisements
upload files to apache ftp server - Ajax
upload files to apache ftp server  hi,sir I want to upload multiple files to apache ftp server. I am using ajax framework for j2ee.Now I am okay for my customize code for my ftp testing.But I want to upload and download to ftp
upload and download files from ftp server using servlet - Ajax
upload and download files from ftp server using servlet  Hi,Sir... for upload and download files from ftp server using servlet and how to use...("Hello FTP Server"); pw.println(""); pw.println("Hello FTP Server
Apache FTP Server
In this tutorial we will discuss on Apache FTP server
How to upload file on FTP Server
How to upload file on FTP Server  In my application there is a requirement of uploading the file on FTP server. How to upload file on FTP Server... is good and can be used in Java applications. Read FTP File Upload in Java for more
Java upload file to ftp
that uploads files on FTP server. You have to use the Apache FTP client library in your program. Apache FTP Client library can be downloaded from apache website...Java upload file to ftp  Hi, How to uploaded file to a ftp server
FTP Server : List Files and Directories
In this tutorial we will discuss how to list files and directories on FTP server using java
How to upload files to server using JSP/Servlet?
How to upload files to server using JSP/Servlet?  How to upload files to server using JSP/Servlet
Java FTP Upload
in Java. View the FTP Server : Upload file example for complete code example...Java FTP Upload  Is there any example code for Java FTP Upload? Which is the easy to use Java FTP Upload example program at roseindia.net? Thanks
FTP Server: List all files name
This tutorial represents how to list the entire files name on FTP server using java
FTP server
FTP server  How to store a series of files in a ftp server using java
FTP Server : Upload file
This tutorial contains description of file uploading to the FTP server using java
ftp server
ftp server  ftp server
ftp server
ftp server  ftp server
ftp server
ftp server  ftp server
Simple FTP upload in Java
Simple FTP upload in Java  How to write a program for Simple FTP upload in Java? Any code example of Simple FTP upload in Java will be very helpful for me. Thanks
FTP Server
FTP Server  i'm working on ftp server if one client has uploaded a file i need to save the details of the user who has uploaded the file like username,filename & ipaddress using java
Java FTP file upload example
Java FTP file upload example  Where I can find Java FTP file upload example? What is the link of the FTP examples on your website? Thanks   Hi, We have many examples of Java FTP file upload. We are using Apache
Image uploading in FTP Server
Image uploading in FTP Server  I want to upload images to a ftp server every 1 hour automatically using java..please help
FTP File Upload in Java
that uploads the file on FTP server. Using Apache FTPClient it's very... a connection to FTP Server and perform upload/download/move/delete operations...); // Upload file to the ftp server
Java Connect to and FTP Server
the apache commons library to connect/login to FTP server. Link of complete example is FTP Server : Connect and Login. Thanks... to and FTP Server? How to establish a connection to FTP server in Java? Thansk
File Upload in FTP - JSP-Servlet
File Upload in FTP  hi sir, i am doing upload files in FTP using java application. is there any jar file to use the privileges of sun.net.ftp. i am writing my program in java servlet. i am getting errors like 1.cannot Find
FTP FILE UPload - JSP-Servlet
FTP FILE UPload  Hi sir, i am doing the file upload via ftp. the program compiled well . but while executing i am getting the below errors... root cause java.lang.NoClassDefFoundError: org/apache/commons/net/ftp
Get all file size on FTP Server
In this section we are going to describe how to get size of FTP server files using java
how to creat ftp server on java
how to creat ftp server on java  ftp server investigation requirment ER diagram flow chart source code
how to creat ftp server on java
how to creat ftp server on java  ftp server investigation requirment ER diagram flow chart source code
how to creat ftp server on java
how to creat ftp server on java  ftp server investigation requirment ER diagram flow chart source code
how to creat ftp server on java
how to creat ftp server on java  ftp server investigation requirment ER diagram flow chart source code
how to creat ftp server on java
how to creat ftp server on java  ftp server investigation requirment ER diagram flow chart source code
how to creat ftp server on java
how to creat ftp server on java  ftp server investigation requirment ER diagram flow chart source code
how to creat ftp server on java
how to creat ftp server on java  ftp server investigation requirment ER diagram flow chart source code
how to creat ftp server on java
how to creat ftp server on java  ftp server investigation requirment ER diagram flow chart source code
FTP Hosting
the user to exchange and store files on your server easy and fast. FTP... of the concept of FTP hosting has made the uploading and downloading files... in FTP are the special software programs that allow the users to exchange files
how to upload file using FTP in java
how to upload file using FTP in java  hai, i want to upload file using FTP in java Webservices.. Tel me some Articles Regards Asha
FTP Programming in Java tutorials with example code
will learn how to create program in Java that connects to FTP server and upload/download the files from FTP server. FTP Servers are very popular for sending files... Java FTP Library Apache FTP Server FTP Server : Connect
Upload and Download Large files in jsp
Upload and Download Large files in jsp  I am not able to download large files (>200mb) from any server. I need a code to download and upload large files (atleast 4 gb) to a server using jsp page
Mutliple files upload
Mutliple files upload  Hi Sir, Am doing a project in Jsp and Servlets, i want to upload multiple files inside the grid of the table, and submit... the following link: http://www.roseindia.net/jsp/file_upload
FTP Server : Remove Directory
In this section you will learn how to delete directory on FTP server using java
FTP Server : Download file
This tutorial contains description of file downloading from the FTP server using java
FTP Server : Connect and Login
In this tutorial we will discuss how to connect and login in FTP server with java programming
FTP Server : Create Directory
In this section you will learn how to create directory on FTP server using java
Upload and Download multiple files
Upload and Download multiple files  Hello Sir/Madam, I need a simple code for upload and download multiple files(it may be image,doc... link: http://www.roseindia.net/jsp/file_upload/uploadingMultipleFiles.shtml
how to copy the directory in to ftp server using java
how to copy the directory in to ftp server using java  how to copy the directory in to ftp server using java ?   Hello venaktehs As much...("MKD"+directoryName); Change the working directory : // Here "ftp" is the Object
Apache Server - Development process
Apache Server  Hi All I have a problem in Apache Software Foundation, Actually in my Apache web server there are run more than one context... out but server continue runs without stoped. Can u tell me why
Tamcat apache server error
Tamcat apache server error  four days before it was working. now its not working HTTP Status 404 - type Status report message description The requested resource () is not available. Apache Tomcat/5.5.31 how to rectify
File Upload and Retrive files
File Upload and Retrive files  Can any body help me am getting an error in uploading file. into mysql database.... thank's in advance
Apache server - Security
Apache server  I am confiure apache webser based httpd.cong file security reason. i am tring to configure port 443 of ssl in apache server.after configuring the apache started well. but nothing to display. it displayed some error
Mutliple files upload
Mutliple files upload  <%@page contentType="text/html" pageEncoding="UTF-8"%> <%@page language="java"%> <%@page import="java.sql...., This my coding in this i have two forms and in second form i have to upload resume
Mutliple files upload
Mutliple files upload   <%@page contentType="text/html" pageEncoding="UTF-8"%> <%@page language="java"%> <%@page import... to upload resume inside the grid view of the table and finally if i submit the page,two
Advertisements
 

 

 

DMCA.com