User Guide

Table Of Contents
Performing file operations with cfftp 1001
After you establish a connection with cfftp, you can reuse the connection to perform additional
FTP operations until either you or the server closes the connection. When you access an already-
active FTP connection, you do not need to re-specify the username, password, or server. In this
case, make sure that when you use frames, only one frame uses the connection object.
Note: For a single simple FTP operation, such as GetFile or PutFile, you do not need to establish a
connection. Specify all the necessary login information, including the server and any login and
password, in the single
cfftp request.
Caching connections across multiple pages
The FTP connection established by
cfftp is maintained only in the current page unless you
explicitly assign the connection to a variable with Application or Session scope.
Assigning a
cfftp connection to an application variable could cause problems, since multiple
users could access the same connection object at the same time. Creating a session variable for a
cfftp connection makes more sense, because the connection is available to only one client and
does not last past the end of the session.
<cfftp connection=Myftp
action="ListDir"
directory="#cfftp.returnvalue#"
name="dirlist"
stoponerror="Yes">
Use the Myftp connection to get a directory listing.
Use the value returned by the last
cfftp call (the
current directory of the connection) to specify the
directory to list. Save the results in a variable
named dirlist (a query object). Stop processing if
there is an error.
<cfftp action="close" connection="Myftp">
<p>Did the connection close successfully?
<cfoutput>#cfftp.succeeded#</
cfoutput></p>
Close the connection, and do not stop processing
if the operation fails (because you can still use the
results). Instead, display the value of the
cfftp.succeeded variable, which is Yes if the
connection is closed, and
No if the operation failed.
<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>
Display a table with the results of the ListDir FTP
command.
Code Description