cfftp

Lets users implement File Transfer Protocol (FTP) operations.

 <cfftp action="open">

 cfftp(action="open");

cfftp Attribute Reference

action
Required

FTP operation to perform.
open: create an FTP connection
close: terminate an FTP connection Values:
  • open
  • close
  • changedir
  • createdir
  • listdir
  • removedir
  • getfile
  • putfile
  • rename
  • remove
  • getcurrentdir
  • getcurrenturl
  • existsdir
  • existsfile
  • exists
  • quote
  • site
  • allo
  • acct

username

Overrides username specified in ODBC setup.

password

Overrides password specified in ODBC setup.

server

FTP server to which to connect; for example,
ftp.myserver.com

timeout
Default: 30

Value in seconds for the timeout of all operations,
including individual data request operations.

port
Default: 21

Remote port to which to connect

connection

Name of the FTP connection. If you specify the username,
password, and server attributes, and if no connection
exists for them, CFML creates one. Calls to cfftp
with the same connection name reuse the connection.

proxyserver

The proxy server required to access the URL.

retrycount
Default: 1

Number of retries until failure is reported.

stoponerror
Default: NO

Yes: halts processing, displays an appropriate error.
No: populates the error variables

passive
Default: NO

Yes: enable passive mode

transfermode
Default: auto

ASCII FTP transfer mode
Binary FTP transfer mode
Auto FTP transfer mode Values:
  • auto
  • ascii
  • binary

failifexists
Default: YES

Yes: if a local file with same name exists, getFile fails

directory

Directory on which to perform an operation

localfile

Name of the file on the local file system

remotefile

Name of the file on the FTP server file system.

item

Object of these actions: file or directory.

existing

Current name of the file or directory on the remote server.

new

New name of file or directory on the remote server

name

Query name of directory listing.

result

Specifies a name for the structure in which cfftp
stores the returnValue variable. If set, this value
replaces cfftp as the prefix to use when accessing
returnVariable.

attributes

Attributes of the current element: normal or Directory.

passphrase

CF 8+ Used when key is specified. Because private keys are stored in an encrypted form on the client host, the user must supply a passphrase to enable generating the signature.

buffersize

Buffer size in bytes.

secure
Default: NO

CF 8+ yes: enables secure FTP

asciiextensionlist

Delimited list of file extensions that force ASCII
transfer mode, if transferMode = "auto".

key

CF 8+ Public-key-based authentication. Refers to the absolute path to the private key of the user.
Possession of a private key provides authentication by sending a signature created with a private key.
The server must ensure that the key is a valid authentication for the user and that the signature is valid.
Both must be valid to accept the authentication.

actionparam

Used only when action is quote, site, or acct. Specifies the command when action is quote or site; specifies account information when action is acct.

fingerprint

CF 8+ Fingerprint of the host key in the form ssh-dss.ssh-rsa, which is a 16-byte unique identifier for the server attribute that you specify.

systemtype

CF 11.0.3+ Specifies how to parse file list response, specify WINDOWS or UNIX or a class which implements org.apache.commons.net.ftp.FTPFileEntryParser Values:
  • WINDOWS
  • UNIX

Compatibility

Lucee:

Lucee does not support authentication by public key.

Links more information about cfftp

Examples sample code using the cfftp tag


Script Syntax

CF 9+ using the CFIDE script components

// Create FTP service and set attributes for connection 
 ftpService = new ftp(); 
 ftpService.setConnection("myConn"); 
 ftpService.setUsername("myUName"); 
 ftpService.setPassword("myPW"); 
 ftpService.setServer("ftp.server.com"); 
 ftpService.setStopOnError(true); 
 // Open connection 
 ftpService.open(); 
 // Get list of dir 
 fileList = ftpService.listdir(directory = "/ ", name="fileList", stopOnError = true).getResult(); 
 // Close connection 
 ftpService.close();

Open Connection

<cfftp action="open" connection="myConn" username="myUName" password="myPW" server="ftp.server.com" stopOnError="true">

Get List of Directories

<cfftp action="listdir" connection="myConn" name="filesList" directory="/" stopOnError="true">

Close Connection

<cfftp action="close" connection="myConn" stopOnError="true">

Fork me on GitHub