Main Content


Change or view current folder on FTP server



cd(ftpobj,folder) changes the current folder on the FTP server associated with ftpobj.

cd(ftpobj) displays the path to the current folder on the server.

newFolder = cd(___) also returns the path as a character vector. You can use the input arguments from either of the previous syntaxes. If you use the first syntax, then newFolder is the path after you change the folder.


collapse all

Connect to an FTP server and navigate to a folder on that server.

First, connect to the National Centers for Environmental Information (NCEI) FTP server.

ftpobj = ftp('')
ftpobj = 

  FTP Object
     user: anonymous
      dir: /
     mode: binary

Display the contents of the top-level folder. It contains another folder named pub.

DMSP                         Solid_Earth                  google12c4c939d7b90761.html  mgg                          
INDEX.txt                    coastwatch                   hazards                      pub                          
README.txt                   dmsp4alan                    index.html                   tmp                          
STP                          ftp.html                     international                wdc                          
Snow_Ice                     geomag                       ionosonde                                                 

Change folders to the pub folder. Then display its contents.

ans = 
WebCD     coast     glac_lib  krm       outgoing  results   rgon                                                                  

FTP service courtesy of the National Centers for Environmental Information (NCEI). See the NCEI Privacy Policy, Disclaimer, and Copyright for NCEI terms of service.

Input Arguments

collapse all

Connection to an FTP server, specified as an FTP object.

Name of the target folder on the FTP server, specified as a character vector or string scalar. To specify the folder above the current one, use '..'.

See Also


Introduced before R2006a