BackUp LevelNext

File and Directory Operations with CFFTP

Use this form of the CFFTP tag to perform file and directory operations with CFFTP.

If you use connection caching to an already active FTP connection, you don't need to respecify the connection attributes:

Syntax

<CFFTP
    ACTION="action"
    USERNAME="name"
    PASSWORD="password"
    NAME="query_name"
    SERVER="server"
    ASCIIEXTENSIONLIST="extensions"
    TRANSFERMODE="mode"
    FAILIFEXISTS="Yes/No"
    DIRECTORY="directory name"
    LOCALFILE="filename"
    REMOTEFILE="filename"
    ATTRIBUTES="file attributes"
    ITEM="directory or file"
    EXISTING="file or directory name"
    NEW="file or directory name"
    PROXYSERVER="proxyserver"
    PROXYBYPASS="proxybypass">

ACTION

Required if connection is not already cached. If connection caching is used, the ACTION attribute is not required. Determines the FTP operation to perform. Can be one of the following:

Note: Names of objects (files and directories) are case-sensitive. Thus a ListDir on test.log will not find test.LOG.

USERNAME

Required if the FTP connection is not already cached. If connection caching is used, the USERNAME attribute is not required. User name to pass in the FTP operation.

PASSWORD

Required if the FTP connection is not already cached. If connection caching is used, the PASSWORD attribute is not required. Password to log the user.

NAME

Required for ACTION="ListDir". Specifies the query name to hold the directory listing.

SERVER

Required if the FTP connection is not already cached. If connection caching is used, the SERVER attribute is not required. The FTP server to connect to.

TIMEOUT

Optional. Value in seconds for the timeout of all operations, including individual data request operations. Defaults to 30 seconds.

PORT

Optional. The remote port to connect to. Defaults to 21 for FTP.

CONNECTION

Optional. The name of the FTP connection. Used to cache the current FTP connection or to reuse connection information from a previous connection of the same name. All calls to CFFTP with the same connection name will reuse the same FTP connection information.

ASCIIEXTENSIONLIST

Optional. A semicolon delimited list of file extensions that force ASCII transfer mode when TRANSFERMODE="Autodetect". Default extension list is:

txt;htm;html;cfm;cfml;shtm;shtml;css;asp;asa

TRANSFERMODE

Optional. The FTP transfer mode you want to use. Valid entries are ASCII, Binary, or Autodetect. Defaults to Autodetect.

AGENTNAME

Optional. Application or entity conducting transfer.

FAILIFEXISTS

Optional. Yes or No. Defaults to Yes. Specifies whether a GetFile operation will fail if a local file of the same name already exists.

DIRECTORY

Required for ACTION=ChangeDir, CreateDir, ListDir, and ExistsDir. Specifies the directory on which to perform an operation.

LOCALFILE

Required for ACTION=GetFile, and PutFile. Specifies the name of the file on the local file system.

REMOTEFILE

Required for ACTION=GetFile, PutFile, and ExistsFile. Specifies the name of the file on the FTP server's file system.

ATTRIBUTES

Optional. Defaults to "Normal." A comma delimited list of file attributes. Specifies the file attributes for the local file in a GetFile. Can be any combination of the following:

File attributes differ according to environment.

ITEM

Required for ACTION=Exists, and Remove. Specifies the object, file or directory, of these actions.

EXISTING

Required for ACTION=Rename. Specifies the current name of the file or directory on the remote server.

NEW

Required for ACTION=Rename. Specifies the new name of the file or directory on the remote server.

RETRYCOUNT

Optional. Number of retries until failure is reported. Default is one (1).

STOPONERROR

Optional. Yes or No. When Yes, halts all processing and displays an appropriate error. Default is No.

When No, three variables are populated:

PROXYSERVER

Optional. A string that contains the name of the proxy server (or servers) to use if proxy access was specified. If this parameter is NULL, the tag reads proxy information from the registry.

PROXYBYPASS

Optional. An optional list of host names or IP addresses, or both, that are known locally. Requests to these names are not routed through the proxy. The list can contain wildcards, such as "157.55.* *int*", meaning any IP address starting with 157.55, or any name containing the substring "int", will bypass the proxy. If this parameter specifies the "<local>" macro as the only entry, the tag bypasses any host name that does not contain a period. For example, "www.microsoft.com" is routed to the proxy, whereas "internet" is not. If this parameter is NULL, the tag reads the bypass list from the registry.

Connection caching

Once you've established a connection with CFFTP, you can reuse the connection to perform additional FTP operations. To do this, you use the CONNECTION attribute to define and name an FTP connection object that stores information about the connection. Any additional FTP operations that use the same CONNECTION name automatically make use of the information stored in the connection object. This facility helps save connection time and drastically improves file transfer operation performance.

Note

Changes to a cached connection, such as changing RETRYCOUNT or TIMEOUT values, may require reestablishing the connection.

Example

The following example opens an FTP connection, retrieves a file listing, showing file or directory name, path, URL, length, and modification date. Connection caching is used to maintain the link to the server, and automatic error checking is enabled.

<CFFTP CONNECTION=FTP 
    USERNAME="betauser" 
    PASSWORD="monroe" 
    SERVER="beta.company.com" 
    ACTION="Open" 
    STOPONERROR="Yes"> 


<CFFTP CONNECTION=FTP 
    ACTION="GetCurrentDir" 
    STOPONERROR="Yes"> 
 
<CFOUTPUT> 
    FTP directory listing of #cfftp.returnvalue#.<p> 
</CFOUTPUT> 
 
    <CFOUTPUT>Return is #cfftp.returnvalue#</CFOUTPUT><BR> 
 
<CFFTP CONNECTION="FTP" 
    ACTION="listdir" 
    DIRECTORY="/*." 
    NAME="q" 
    STOPONERROR="Yes">

<HR>FTP Directory Listing:<P> 
<CFTABLE QUERY="q" 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="Date(Format#lastmodified#)">   
    <CFCOL HEADER="<B>IsDirectory</B>" TEXT="#isdirectory#"> 
</CFTABLE>


BackUp LevelNext

allaire

AllaireDoc@allaire.com
Copyright © 1998, Allaire Corporation. All rights reserved.