hello all i am trying to upload a small file like 4mb or something with apache commons ftpclient it do not upload my file and gives me no error and says upload successfull this is my code please help me thanx in advance.. here goes the code..

 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();
有帮助吗?

解决方案

client.changeWorkingDirectory(str);

is it likely that the str directory does not exist, as the dir you are creating is "/public_html/"+str.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top