Performing File Operations with cfftp
Code
<cfftp connection=Myftp
<cfftp action="close"
connection="Myftp">
<p>Did the connection close
successfully?
cfoutput></p>
<cftable query="dirlist"
</cftable>
hafter you establish a connection with
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
Caching connections across multiple pages
The FTP connection established by
unless you explicitly assign the connection to a variable with Application or Session
scope.
action="ListDir"
directory="#cfftp.returnvalue#"
name="dirlist"
stoponerror="Yes">
<cfoutput>#cfftp.succeeded#</
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#">
Description
Use the Myftp connection to get a
directory listing. Use the value returned
by the last
cfftp
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.
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
Yes if the connection is closed, and No
if the operation failed.
Display a table with the results of the
ListDir FTP command.
, you can reuse the connection to
cfftp
request.
cfftp
is maintained only in the current page
cfftp
343
call (the current
variable, which is
Need help?
Do you have a question about the COLDFUSION 5-DEVELOPING and is the answer not in the manual?
Questions and answers