سؤال

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