2

大家好,我正在尝试使用 apache commons ftpclient 上传一个像 4mb 这样的小文件,它不会上传我的文件并且没有给我任何错误,并说上传成功这是我的代码,请提前帮助我thanx ..这里是代码。 .

 new Thread(new Runnable() {
            public void run() {
                Looper.prepare();

                FTPClient client = new FTPClient();

                try {  
                        boolean  result = false;
                        FileInputStream fis = null;

                        client.connect(server);
                        client.enterLocalPassiveMode();
                        client.login(user, pass);
                        client.makeDirectory("/public_html/"+str); ///str is a name of remote folder

                        client.setFileType(FTP.BINARY_FILE_TYPE);
                        client.setFileTransferMode(FTP.BINARY_FILE_TYPE );
                        client.changeWorkingDirectory(str);
                        String path1 = Environment.getExternalStorageDirectory() + "/index.htm";
                        File f = new File(path1);
                        String testname = f.getName();

                        fis = new 
                                FileInputStream(f);
                        result = client.storeFile(testname, fis);

                        if (result == true){
                            Log.v("upload","upload successfull");
                        }
                        else{
                            Log.v("upload", "upload failed");
                        }
                 catch (Exception e) {
                      e.printStacktrace();
                 }
            } 
          }).start();
4

1 回答 1

1
client.changeWorkingDirectory(str);

str目录是否可能不存在,因为您正在创建的目录是"/public_html/"+str.

于 2013-07-09T14:53:22.023 回答