cfftp

Lets users implement File Transfer Protocol (FTP) operations.

 <cfftp action="open">

 cfftp(action="open");

Attribute Reference for the cfftp tag

action

Required: Yes
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

Required: No
Overrides username specified in ODBC setup.

password

Required: No
Overrides password specified in ODBC setup.

server

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

timeout

Required: No
Default: 30
Value in seconds for the timeout of all operations,
including individual data request operations.

port

Required: No
Default: 21
Remote port to which to connect

connection

Required: No
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

Required: No
The proxy server required to access the URL.

retrycount

Required: No
Default: 1
Number of retries until failure is reported.

stoponerror

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

passive

Required: No
Default: NO
Yes: enable passive mode

transfermode

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

failifexists

Required: No
Default: YES
Yes: if a local file with same name exists, getFile fails

directory

Required: No
Directory on which to perform an operation

localfile

Required: No
Name of the file on the local file system

remotefile

Required: No
Name of the file on the FTP server file system.

item

Required: No
Object of these actions: file or directory.

existing

Required: No
Current name of the file or directory on the remote server.

new

Required: No
New name of file or directory on the remote server

name

Required: No
Query name of directory listing.

result

Required: No
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

Required: No
Attributes of the current element: normal or Directory.

passphrase

Required: No
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

Required: No
Buffer size in bytes.

secure

Required: No
Default: NO
CF 8+ yes: enables secure FTP

asciiextensionlist

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

key

Required: No
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

Required: No
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

Required: No
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

Required: No
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