User Guide

Performing File Operations with cfftp 341
Performing File Operations with cfftp
The cfftp tag lets you perform tasks on remote servers using File Transfer Protocol
(FTP). You can use
cfftp to cache connections for batch file transfers.
Note
To use cfftp, the Enable cfftp Tag option must be selected on the Tag Restrictions
page of the Basic Security section of the ColdFusion Administrator Security tab.
For server/browser operations, use the
cffile, cfcontent, and cfdirectory tags.
Using
cfftp involves two major types of operations: connecting, and transferring
files. The FTP protocol also provides commands for listing directories and
performing other operations. For a complete list of attributes that support FTP
operations and additional details on using the
cfftp tag, see the CFML Reference.
To open an FTP connection and retrieve a file listing:
1 Open a new file in ColdFusion Studio.
2 Modify the file so that it appears as follows:
<html>
<head>
<title>FTP Test</title>
</head>
<body>
<h1>FTP Test</h1>
<!--- Open ftp connection --->
<cfftp connection="Myftp"
server="MyServer"
username="MyUserName"
password="MyPassword"
action="Open"
stoponerror="Yes">
<!--- Get the current directory name. --->
<cfftp connection=Myftp
action="GetCurrentDir"
stoponerror="Yes">
<!--- output directory name --->
<cfoutput>
The current directory is: #cfftp.returnvalue#<p>
</cfoutput>
<!--- Get a listing of the directory. --->
<cfftp connection=Myftp
action="listdir"
directory="#cfftp.returnvalue#"
name="dirlist"
stoponerror="Yes">