Object to connect to FTP server and access its files
Connect to an FTP server by calling the ftp
function,
which creates an FTP object. To access a particular FTP account on the server, specify a
user name and password. Then use the FTP object to upload and download files. You also
can create, delete, and navigate to different folders on the server. To close the
connection, use the close
function.
Note
Because FTP is not a secure protocol, the FTP object does not encrypt your user name, your password, or any data you download from or upload to an FTP server. If you require a secure FTP connection, then use an SFTP client provided by your system.
ftpobj = ftp(
opens a
connection to the FTP server host
)host
and stores the connection
in FTP object ftpobj
. To use this syntax,
host
must support anonymous connections.
ftpobj = ftp(
specifies additional input arguments using one or more name-value pair
arguments. For example, you can specify the value of host
,username
,password
,Name,Value
)'System'
as 'WINDOWS'
to connect to an FTP server that runs a
Windows® operating system. You also can specify the value of
'LocalDataConnectionMethod'
to change the connection mode
from passive to active mode.
ascii | Set FTP transfer mode to ASCII |
binary | Set FTP transfer mode to binary |
cd | Change or view current folder on FTP server |
close | Close connection to FTP server |
delete | Delete file on FTP server |
dir | List folder contents on FTP server |
mget | Download files from FTP server |
mkdir | Make new folder on FTP server |
mput | Upload file or folder to FTP server |
rename | Rename file on FTP server |
rmdir | Remove folder on FTP server |
The FTP object does not support proxy server settings.
While it is unnecessary to specify the 'System',systemKey
name-value pair, the FTP dir
function might return less
information if the FTP object is not configured for the operating system running
on the FTP server. In such cases, dir
might return a
structure array with some empty fields. In that case, call
ftp
again and specify the correct value for
systemKey
.
The code for the FTP object is based on code from the Apache™ Project.
In particular, the ftp
function configures properties for FTP
connections as specified by the Apache
FTPClientConfig
class. Any settable
property of the FTPClientConfig
class can be set using the
ftp
function with the corresponding name-value pair
argument.