You can try This Example : FTP Example
It will getting you exact idea for how to implement FTP functionality.
Question
I was working on android FtpClient which is not uploading any file from the sdcard to the FTPServer and is not throwing any exception so i couldn't see any error on this code please someone help me to fix this
code
Button upload=(Button)findViewById(R.id.upload);
upload.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
try {
Log.i(TAG, "upload");
final String FPATH = fileLocal.getPath();
Filename filename = new Filename(FPATH, '/', '.');
System.out.println("Extension = " + filename.extension());
System.out.println("Filename = " + filename.filename());
System.out.println("Path = " + filename.path().replace("/mnt/", ""));
System.out.println("--------------------------------------------------------------");
System.out.println("srcFilePath = " + fileLocal.getPath());
System.out.println("desFileName = " + filename.filename()+"."+filename.extension());
System.out.println("desDirectory = " + "/");
ftpClient.ftpUpload(fileLocal.getPath().replace("/mnt/", ""), filename.filename()+"."+filename.extension(),"/", monContext);
//Refresh list
uploadRefresh();
} catch (Exception e) {
System.out.println("sarath:from upload");
e.printStackTrace();
}
}
});
this is my logcat
02-24 15:51:00.320: I/System.out(12279): --------------------------------------------------------------
02-24 15:51:00.320: I/System.out(12279): srcFilePath = /mnt/sdcard/b.class
02-24 15:51:00.320: I/System.out(12279): desFileName = b.class
02-24 15:51:00.320: I/System.out(12279): desDirectory = /
02-24 15:51:00.344: D/UploadActivity(12279): List directory of server1 : /
02-24 15:51:00.344: D/UploadActivity(12279): recuperation des données du repertoires
02-24 15:51:00.391: D/UploadActivity(12279): liste des repertoire : $RECYCLE.BIN
02-24 15:51:00.391: D/UploadActivity(12279): liste des repertoire : Android
02-24 15:51:00.391: D/UploadActivity(12279): liste des repertoire : Juno
02-24 15:51:00.391: D/UploadActivity(12279): liste des repertoire : Juno.rar
02-24 15:51:00.391: D/UploadActivity(12279): liste des repertoire : KodSpider Workspace
02-24 15:51:00.399: D/UploadActivity(12279): liste des repertoire : System Volume Information
02-24 15:51:00.399: D/UploadActivity(12279): nombre de file dans le repertoire : 6
02-24 15:51:00.399: I/UploadActivity(12279): Directory : $RECYCLE.BIN
02-24 15:51:00.399: I/UploadActivity(12279): Directory : Android
02-24 15:51:00.399: I/UploadActivity(12279): Directory : Juno
02-24 15:51:00.399: I/UploadActivity(12279): File : Juno.rar
02-24 15:51:00.399: I/UploadActivity(12279): Directory : KodSpider Workspace
02-24 15:51:00.399: I/UploadActivity(12279): Directory : System Volume Information
Solution
You can try This Example : FTP Example
It will getting you exact idea for how to implement FTP functionality.