User Guide

342 Chapter 18 Interacting with Remote Servers
<!--- Close the connection.--->
<cfftp action="close" connection="Myftp">
<p>Did the connection close successfully?
<cfoutput>#cfftp.succeeded#</cfoutput></p>
<!--- output dirlist results --->
<hr>
<p>FTP Directory Listing:</p>
<cftable query="dirlist" colheaders="yes" htmltable>
<cfcol header="<B>Name</b>" TEXT="#name#">
<cfcol header="<B>Path</b>" TEXT="#path#">
<cfcol header="<B>URL</b>" TEXT="#url#">
<cfcol header="<B>Length</b>" TEXT="#length#">
<cfcol header="<B>LastModified</b>"
TEXT="#DateFormat(lastmodified)#">
<cfcol header="<B>IsDirectory</b>"
TEXT="#isdirectory#">
</cftable>
3Change MyServer to the name of a server for which you have FTP permission.
4Change
MyUserName and MyPassword to a valid username and password.
To establish an anonymous connection, enter anonymous as the username
and an e-mail address (by convention) for the password.
5 Save the file as
ftpconnect.cfm in myapps under your Web root directory.
Reviewing the code
The following table describes the code and its function:
Code Description
<cfftp connection="Myftp"
server="MyServer"
username="MyUserName"
password="MyPassword"
action="Open"
stoponerror="Yes">
Open an FTP connection to the
MyServer server and log on as
MyUserName. If an error occurs, stop
processing and display an error. You
can use this connection in other cfftp
tags by specifying the Myftp connection.
<cfftp connection=Myftp
action="GetCurrentDir"
stoponerror="Yes">
<cfoutput>
The current directory is:
#cfftp.returnvalue#<p>
</cfoutput>
Use the Myftp connection to get the
name of the current directory; stop
processing if an error occurs.
Display the current directory.