User Guide

Table Of Contents
1000 Chapter 40: Interacting with Remote Servers
name="dirlist"
stoponerror="Yes">
<!--- 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>
2.
Change MyServer to the name of a server for which you have FTP permission.
3.
Change 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.
4.
Save the file as ftp_connect.cfm in the myapps directory under your web_root and view it in the
web browser.
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.