Hochladen einer Datei auf einen FTP-server aus android-Handy?

Folgenden ist der code, den wir erstellen eine text-Dokument und laden Sie Sie auf meinem FTP-server. Aus irgendeinem Grund scheint es nicht zu funktionieren. Ich verwendet, um die Bibliotheken bei

http://lavalatwork.blogspot.tw/2010/09/using-apache-commons-ftp-library-in.html

für die Kommunikation mit dem FTP-server.

try
    {
        final String testString = new String("Hello");
        FileOutputStream fOut = openFileOutput("samplefile.txt",
                MODE_WORLD_READABLE);
        OutputStreamWriter osw = new OutputStreamWriter(fOut); 

        osw.write(testString);
        osw.flush();
        osw.close();
    }


    catch(IOException ex)
    {

    }


    FTPClient mFTP = new FTPClient();
    try {
        //Connect to FTP Server
        mFTP.connect("192.168.10.101");
        //mFTP.login("user", "password");
        mFTP.setFileType(FTP.BINARY_FILE_TYPE);
        mFTP.enterLocalPassiveMode();

        //Prepare file to be uploaded to FTP Server
        File file = new File(getFileStreamPath("samplefile.txt")+ "");
        FileInputStream ifile = new FileInputStream(file);

        //Upload file to FTP Server
        mFTP.storeFile("filetotranfer",ifile);
        mFTP.disconnect();          
    } catch (SocketException e) {
        //TODO Auto-generated catch block
        e.printStackTrace();
    } catch (IOException e) {
        //TODO Auto-generated catch block
        e.printStackTrace();
    }

Jede mögliche Hilfe würde geschätzt.

  • Überprüfen Sie die Ausgabe von logcat ist oft sehr hilfreich, wenn Sie mithilfe von Apache Commons FTP-client.
  • Bitte explizit, was genau nicht funktioniert. Und poste deine logcat.
Schreibe einen Kommentar