I am trying to do ftp to local host. but im getting error
03-03 00:49:40.747: WARN/System.err(4151): java.net.ConnectException: /127.0.0.1:1160 – Connection refused
03-03 00:49:40.758: WARN/System.err(4151): at org.apache.harmony.luni.net.PlainSocketImpl.connect(PlainSocketImpl.java:255)
And the code follows like this
FTPClient ftp;
server = "10.0.2.2";
username = "newuser";
password = "wampp";
remote = "/sample.txt";
local = "/data/data/com.test.sample/files/sample/sample.txt";
ftp = new FTPClient();
InputStream input;
input = new FileInputStream(local);
ftp.storeFile(remote, input);
input.close();
I am using XAMPP server as my localhost. It Contains FileZilla. Same code works fine as normal java application.
It doesn’t appear that you’re actually using the server, username or password variables. Take a look at this example to get some direction:
http://hoang17.com/posts/android/android-how-to-upload-a-file-via-ftp