Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>if all you need is uploading files via ftp from android to web server, this will do the trick (working from froyo up - BUT you must import <a href="http://commons.apache.org/net/download_net.cgi" rel="nofollow">apache commons</a> and install a copy inside your "src" folder):</p> <pre><code>import java.io.FileInputStream; import org.apache.commons.net.ftp.FTPClient; import android.util.Log; public class FtpFileUp implements Runnable { private final String TAG = "FTPfile"; boolean flagFTPOK = false; String fileName, fileDirSubLocalName, fileDirSubRemoteName; String fileDirName = NavigationActivity.fileDirName; FtpFileUp (String fileNameIn, String fileDirSubLocalNameIn, String fileDirSubRemoteNameIn) { fileName = (String) fileNameIn; fileDirSubLocalName = (String) fileDirSubLocalNameIn; fileDirSubRemoteName = (String) fileDirSubRemoteNameIn; } FtpFileUp (String fileNameIn) { String fileDirSubNameIn = ""; fileName = (String) fileNameIn; fileDirSubLocalName = (String) fileDirSubNameIn; fileDirSubRemoteName = (String) fileDirSubNameIn; } FtpFileUp (String fileNameIn, String fileDirSubNameIn) { fileName = (String) fileNameIn; fileDirSubLocalName = (String) fileDirSubNameIn; fileDirSubRemoteName = (String) fileDirSubNameIn; } @Override public void run() { String ftpConnectString = "ftp.yourdomain.com"; if (fileDirSubRemoteName != "") fileDirSubRemoteName += "/"; if (fileDirSubLocalName != "") fileDirSubLocalName += "/"; FTPClient ftpCli = new FTPClient(); try { FileInputStream fis = new FileInputStream(fileDirName+"/"+fileDirSubLocalName+fileName); ftpCli.connect(ftpConnectString); ftpCli.login("user", "password"); Log.i(TAG, "ok ftp "+ftpCli.getDataConnectionMode()); ftpCli.storeFile("/"+fileDirSubRemoteName+fileName, fis); fis.close(); flagFTPOK = true; } catch (Exception except) { Log.i(TAG, "ftp up FAIL "+except); } } } </code></pre> <p>which you would call using the following code (encapsulated by TRY CATCH)</p> <pre><code>Thread ftpThread01 = new Thread(new FtpFileUp("fileName", "", "/www/android/imgUpload")); ftpThread01.start(); </code></pre> <p>NOTE: as you can see, there are 2 alternative constructors that you may use to automatize your ftp, by storing default locations. they may be removed with no harm.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload