| Contents | Index |
Connect to FTP server
Connect to an FTP server by calling the ftp function, which creates an FTP object. Perform file operations using methods on the FTP object, such as mput and mget. When you finish accessing the server, call the close method to close the connection.
f = ftp(host,username,password) connects to the FTP server host and creates FTP object f. If the host supports anonymous connections, you can use the host argument alone. To specify an alternate port, separate it from host with a colon (:).
| ascii | Set FTP transfer type to ASCII |
| binary | Set FTP transfer type to binary |
| cd | Change or view current folder on FTP server |
| close | Close connection to FTP server |
| delete | Remove file on FTP server |
| dir | View contents of folder on FTP server |
| mget | Download files from FTP server |
| mkdir | Create folder on FTP server |
| mput | Upload file or folder to FTP server |
| rename | Rename file on FTP server |
| rmdir | Remove folder on FTP server |
Handle. To learn how handle classes affect copy operations, see Copying Objects in the MATLAB Programming Fundamentals documentation.
Connect to the MathWorks FTP server, and display the FTP object:
mw=ftp('ftp.mathworks.com');
disp(mw)MATLAB returns:
FTP Object host: ftp.mathworks.com user: anonymous dir: / mode: binary
Connect to port 34 (not supported at ftp.mathworks.com, so this code returns an error):
mw=ftp('ftp.mathworks.com:34')Modify the following code to connect to a host that requires a password:
test=ftp('ftp.testsite.com','myname','mypassword')The ftp function is based on code from the Apache Jakarta Project.

Explore how to use MATLAB to make advancements in engineering and science.
| © 1984-2012- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |