User Guide

Chapter 15: Interacting with Remote Servers 239
Performing File Operations with CFFTP
The CFFTP tag allows you to perform tasks on remote servers via the File Transfer
Protocol (FTP). CFFTP allows you to cache connections for batch file transfers.
Note In order to use CFFTP, make sure CFOBJECT is enabled on the Basic
Security page of the ColdFusion Administrator.
For server/browser operations, use the CFFILE, CFCONTENT, and CFDIRECTORY
tags.
Note CFFTP is a COM object and is not supported in Microsoft Windows NT
3.51.
Using CFFTP involves two distinct types of operations, connecting and transferring
files. For a complete list of attributes, see the CFML Language Reference .
To open an FTP connection and retrieve a file listing:
1. Open a new file in Studio.
2. Modify the file so that it appears as follows:
<--- open FTP connection --->
<CFFTP CONNECTION=FTP
USERNAME="betauser"
PASSWORD="monroe"
SERVER="beta.company.com"
ACTION="Open"
STOPONERROR="Yes">
<--- get current directory name --->
<CFFTP CONNECTION=FTP
ACTION="GetCurrentDir"
STOPONERROR="Yes">
<--- output directory name --->
<CFOUTPUT>
FTP directory listing of #cfftp.returnvalue#.<p>
</CFOUTPUT>
<--- get directory info --->
<CFFTP CONNECTION=FTP
ACTION="listdir"
DIRECTORY="/*."
NAME="q"
STOPONERROR="Yes">
<--- output dirlist results --->
<HR>
<P>FTP Directory Listing:</P>
<CFTABLE QUERY="q" HTMLTABLE>