O'Reilly logo

Programming ColdFusion MX, 2nd Edition by Rob Brooks-Bilson

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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"
       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.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 Anonymous. As a matter of convention ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required