开发者

Android - FTP problem in Android

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


How is your android device connected to the network?? Can you even ping 10.0.2.2 from the device itself??

I suggest installing busybox on your android device, it has telnet and ftp commands to test your FTP server. If you cannot access your ftp from busybox/android shell, than you have firewall or port forwarding issues.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜