This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materials including this page, select Japan from the country navigator on the bottom of this page.

FTP class

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 (:).

Input Arguments


Character vector or string that specifies the FTP server.


Character vector or string that specifies your user name for the FTP server.


Character vector or string that specifies your password for the FTP server. Because FTP is not a secure protocol, others can see your user name and password.


asciiSet FTP transfer type to ASCII
binarySet FTP transfer type to binary
cdChange or view current folder on FTP server
closeClose connection to FTP server
deleteRemove file on FTP server
dirView contents of folder on FTP server
mgetDownload files from FTP server
mkdirCreate folder on FTP server
mputUpload file or folder to FTP server
renameRename file on FTP server
rmdirRemove folder on FTP server

Copy Semantics

Handle. To learn how handle classes affect copy operations, see Copying Objects.


Connect to an FTP server and display the FTP object. Replace with the URL for an actual FTP site.

ts = ftp('');

Connect to port 34. If you specify a port that the FTP server does not support, then ftp returns an error.

ts = ftp('')

Modify the following code to connect to a host that requires a password:

ts = ftp('','myname','mypassword')


The ftp function does not support proxy server settings.


The ftp function is based on code from the Apache Jakarta Project.

See Also

Introduced before R2006a

Was this topic helpful?