# Is it possible to upload image files to the ftp server through'processing'?

**URL:** <https://discourse.processing.org/t/is-it-possible-to-upload-image-files-to-the-ftp-server-throughprocessing/28115>\
**Category:** Processing for Android\
**Tags:** homework\
**Created:** [February 27, 2021, 3:09pm UTC](https://discourse.processing.org/t/is-it-possible-to-upload-image-files-to-the-ftp-server-throughprocessing/28115 "2021-02-27T15:09:31Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![GWAK](https://avatars.discourse-cdn.com/v4/letter/g/13edae/32.png) [@GWAK](https://discourse.processing.org/u/GWAK)\
**Post date:** [February 27, 2021, 3:09pm UTC](https://discourse.processing.org/t/is-it-possible-to-upload-image-files-to-the-ftp-server-throughprocessing/28115/1 "2021-02-27T15:09:31Z")

</div>

Is it possible to upload image files to the ftp server through’processing’?

1. Select a picture stored on the smartphone.

2. I want to transfer the saved picture to the ftp server.

Is there a method or sample code? Help.

---

<div class="post-metadata">

**Author:** ![GWAK](https://avatars.discourse-cdn.com/v4/letter/g/13edae/32.png) [@GWAK](https://discourse.processing.org/u/GWAK)\
**Post date:** [February 27, 2021, 4:01pm UTC](https://discourse.processing.org/t/is-it-possible-to-upload-image-files-to-the-ftp-server-throughprocessing/28115/2 "2021-02-27T16:01:19Z")

</div>

> import it.sauronsoftware.ftp4j.FTPClient;  
> import it.sauronsoftware.ftp4j.FTPDataTransferListener;  
> import java.io.File;  
> import android.app.Activity;  
> import android.os.Bundle;  
> import android.view.View;  
> import android.view.View.OnClickListener;  
> import android.widget.Button;  
> import android.widget.Toast;  
> import android.os.Environment;
> 
> static final String FTP\_HOST= “…”;  
> static final String FTP\_USER = “…”;  
> static final String FTP\_PASS =“…”;  
> String my\_folder = “TEST\_FTP”;
> 
> PImage photo;  
> void setup(){
> 
> int Start\_ms = millis();  
> fullScreen();  
> String link = Environment.getExternalStorageDirectory().getAbsolutePath()+“/”+my\_folder+“/1.jpg”;  
> println(" LINK1 : " + link);  
> link = “/storage/emulated/0/2.png”; photo = loadImage(link);
> 
> // link = Environment.getExternalStorageDirectory()+“1.jpg”;  
> // println(" LINK2 : " + link);
> 
> File f = new File(link);  
> uploadFile(f);  
> println(" ms : " + str(millis()-Start\_ms) );
> 
> }
> 
> void draw(){
> 
> if( photo != null ) { image(photo,0,0); }
> 
> }
> 
> ```
> public void uploadFile(File fileName){         
>      
> FTPClient client = new FTPClient();
>       
> try {
>          
> client.connect(FTP_HOST,21);
> client.login(FTP_USER, FTP_PASS);
> client.setType(FTPClient.TYPE_BINARY);
> // client.changeDirectory("/upload/");
>          
> client.upload(fileName, new MyTransferListener());
>          
> } catch (Exception e) {
> e.printStackTrace();
> try {
> client.disconnect(true);    
> } catch (Exception e2) {
> e2.printStackTrace();
> }
> }
>      
> }
>  
> public class MyTransferListener implements FTPDataTransferListener {
> 
> public void started() {
>          
> System.out.println(" INIT" );
>         
> } 
> public void transferred(int length) {
> System.out.println(" transferred" );
> } 
> public void completed() {
> System.out.println(" completed" );
> } 
> public void aborted() {
> 
> System.out.println(" aborted" );
> } 
> public void failed() {
> 
> System.out.println(" failed" );
> }
> 
> }
> 
> ```

I solved it.

> **[FTP File Upload From Sdcard to server](https://androidexample.com/ftp-file-upload)**
>
> In this example uploading file on server by ftp client ( with the use of ftp4j-1.6.jar ).
