Performing FTP Operations
As we’ve already discussed, the
CFFILE
tag allows you to upload files from a
client machine to the ColdFusion server and perform file and
directory operations on your ColdFusion server. When you need to work
with files and directories on a remote server, however, you need to
use the CFFTP
tag instead.
Connecting to a Remote Server
FTP operations using
the CFFTP
tag begin by opening a connection to the
remote FTP server. The following example shows how to connect to an
anonymous FTP server using the CFFTP
tag:
<CFFTP ACTION="Open" SERVER="ftp.microsoft.com" PORT="21" USERNAME="anonymous" PASSWORD="YourEmailAddress@yourdomain.com" CONNECTION="MyConnection" AGENTNAME="MyFTPClient" PROXYSERVER="MyProxyServer" PROXYBYPASS="127.0.0.1" RETRYCOUNT="3" TIMEOUT="60" STOPONERROR="No" PASSIVE="No">
To open the connection to the remote FTP server, we set the
ACTION
parameter of the CFFTP
tag to Open
. There are several additional
parameters available for the ACTION
attribute that
will be discussed later in this section. The
SERVER
attribute specifies the hostname or IP
address of the remote server with which to open an FTP session. In
this case, we want to connect to Microsoft’s public FTP server
at ftp://ftp.microsoft.com. The
PORT
attribute specifies what port the
CFFTP
tag should try to connect to. This attribute
is optional and defaults to the standard FTP port 21. Because
Microsoft allows anonymous access to their FTP server, we set the
USERNAME
attribute to ...
Get Programming ColdFusion now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.