User Guide

240 Developing Web Applications with ColdFusion
<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="Date(Format#lastmodified#)">
<CFCOL HEADER="<B>IsDirectory</B>"
TEXT="#isdirectory#">
</CFTABLE>
3. Change beta.company.com to the name of a server you have permission to FTP to.
4. Change
betauser and monroe to a valid username and password.
To establish an anonymous connection enter "anonymous" as the username and
an email address (by convention) for the password.
5. Save the file as
ftpconnect.cfm in myapps under your Web root directory.
Once you’ve established a connection with CFFTP, you can reuse the connection to
perform additional FTP operations. When you access an already active FTP
connection, you don’t 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.
Caching connections across multiple pages
CFFTP caching is maintained only in the current page unless you explicitly assign a
CFFTP 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 the most sense.
You cache a connection object for a session by assigning the connection name to a
session variable:
Example: Caching a connection
<CFFTP ACTION=connect
USERNAME="anonymous"
PASSWORD="me@home.com"
SERVER="ftp.eclipse.com"
CONNECTION="Session.myconnection">
In this example, the connection cache remains available to other pages within the
current session. Of course, you need to be sure that you’ve enabled session variables in
your application first.
Note Changes to a cached connection, such as changing RETRYCOUNT or
TIMEOUT values, may require re-establishing the connection.