ftp server and client using Wizfi310

Dependencies:   FTPClient SDFileSystem WizFi310Interface_Legacynew mbed

Fork of Manas_FTP_SD_card_wizwikiw7500 by Manas Deka

Revision:
3:2b3609dc347a
Parent:
2:a185787cdddf
Child:
4:3ccf1cd64c84
--- a/main.cpp	Thu Dec 14 05:35:51 2017 +0000
+++ b/main.cpp	Wed Jan 03 11:01:52 2018 +0000
@@ -6,8 +6,9 @@
 #include <stdio.h>
 #define FTP_SERVER_PORT     21
  static char buf[256];
+ DigitalIn P1(D2);
 static char ID[]={"FTP"};                   //Set FTPServer Login ID
-static char PASSWORD[]={"user"};  user           //Set FTPServer Login Password
+static char PASSWORD[]={"user"};  //user           //Set FTPServer Login Password
 FTPClient FTP(PB_3, PB_2, PB_1, PB_0, "sd"); // WIZwiki-W7500 
 Serial pc(USBTX, USBRX);
 int main() {
@@ -28,21 +29,14 @@
     eth.connect();
     pc.printf("\nThe IP address of the client is %s\r\n",eth.getIPAddress());
     
-    while(1) {
-       //char Msg_c = pc.getc();
-            
-    //if(Msg_c==0x31)
-    //{
-            
+    while(1) {     
                     pc.printf("\nConnecting...FTPServer\r\nIP:%s, PORT:%d\r\n", ftpServer_control_ip_addr, FTP_SERVER_PORT);
-                    //pc.printf("Test\n");
-                    
+                   
+                   /*TO connect to online Server uncomment the below line*/ 
                     //FTP.open("demo.wftpserver.com");
                     
                     bool n  = FTP.open("192.168.0.100", 21,"FTP","user");
-                    
-                    //pc.printf("%d\r\n",n);
-                     wait(10);
+                   
                     printf("\nThe Files and folders available in the server are :\r\n");
                     FTP.ls();
                     printf("\r\n");
@@ -56,11 +50,30 @@
                     FTP.ls();
                     printf("\r\n");
                     wait(10);
-                     
-      //      }    
-
-             
-     }    
+                    FTP.cd("/image");
+                    FTP.ls();
+                    /*
+                    To get file from server to client use command "getfile" and to upload file from client to server use command "putfile"
+                    //Example of uploading a image file from server to client 
+                    FTP.getfile("/ftp/vlcsnap-3279000.jpg","vlcsnap-3279000.jpg");
+                    printf("succesfull getting image from server");
+                    */
+                    //Uploading a text file from server named as k.txt
+                    FTP.getfile("/ftp/k.txt","k.txt");
+                    FTP.dir();
+                    wait(10);
+                    FTP.cd("/download");
+                    //creating directory/folder 
+                    FTP.mkdir("test1");
+                     FTP.cd("test1");
+                     //Uploading image file from client that is "sd" card in this case to server
+                     //name of image is vlcsnap-3279000.jpg in sd card but will be stored as k.jpg in server
+                    FTP.putfile("/sd/vlcsnap-3279000.jpg","k.jpg");
+                    FTP.dir();
+                    wait(10);
+                    //To disconnect the FTP connection
+                    FTP.quit();
             
 
+}
 }
\ No newline at end of file