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">
Summary of Contents for COLDFUSION 5-DEVELOPING
Page 1: ...Macromedia Incorporated Developing ColdFusion Applications MacroMedia ColdFusion 5 ...
Page 58: ...38 Chapter 3 Querying a Database ...
Page 134: ...114 Chapter 7 Updating Your Database ...
Page 210: ...190 Chapter 10 Reusing Code ...
Page 232: ...212 Chapter 11 Preventing and Handling Errors ...
Page 238: ...218 Chapter 12 Using the Application Framework ...
Page 262: ...242 Chapter 12 Using the Application Framework ...
Page 278: ...258 Chapter 13 Extending ColdFusion Pages with CFML Scripting ...
Page 320: ...300 Chapter 15 Indexing and Searching Data ...
Page 336: ...316 Chapter 16 Sending and Receiving E mail ...
Page 374: ...354 Chapter 18 Interacting with Remote Servers ...