Performing file operations with cfftp
817
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.
Example: caching a connection
<cflock scope="Session" timeout=10>
<cfftp action="Open"
username="anonymous"
password="[email protected]"
server="ftp.eclipse.com"
connection="Session.myconnection">
</cflock>
In this example, the connection cache remains available to other pages within the current session.
You must enable session variables in your application for this approach to work, and you must
lock code that uses session variables. For more information on locking, see
Chapter 15, “Using
Persistent Data and Locking,” on page 315
.
Note:
Changing a connection’s characteristics, such the
retrycount
or
timeout
values, might require
you to re-establish the connection.
<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
Summary of Contents for COLDFUSION MX 61-DEVELOPING COLDFUSION MX
Page 1: ...Developing ColdFusion MX Applications...
Page 22: ...22 Contents...
Page 38: ......
Page 52: ...52 Chapter 2 Elements of CFML...
Page 162: ......
Page 218: ...218 Chapter 10 Writing and Calling User Defined Functions...
Page 250: ...250 Chapter 11 Building and Using ColdFusion Components...
Page 264: ...264 Chapter 12 Building Custom CFXAPI Tags...
Page 266: ......
Page 314: ...314 Chapter 14 Handling Errors...
Page 344: ...344 Chapter 15 Using Persistent Data and Locking...
Page 349: ...About user security 349...
Page 357: ...Security scenarios 357...
Page 370: ...370 Chapter 16 Securing Applications...
Page 388: ...388 Chapter 17 Developing Globalized Applications...
Page 408: ...408 Chapter 18 Debugging and Troubleshooting Applications...
Page 410: ......
Page 426: ...426 Chapter 19 Introduction to Databases and SQL...
Page 476: ...476 Chapter 22 Using Query of Queries...
Page 534: ...534 Chapter 24 Building a Search Interface...
Page 556: ...556 Chapter 25 Using Verity Search Expressions...
Page 558: ......
Page 582: ...582 Chapter 26 Retrieving and Formatting Data...
Page 668: ......
Page 734: ...734 Chapter 32 Using Web Services...
Page 760: ...760 Chapter 33 Integrating J2EE and Java Elements in CFML Applications...
Page 786: ...786 Chapter 34 Integrating COM and CORBA Objects in CFML Applications...
Page 788: ......