For the complete experience, please enable JavaScript in your browser. Thank you!

  • Creative Cloud
  • Photoshop
  • Illustrator
  • InDesign
  • Premiere Pro
  • After Effects
  • Lightroom
  • See all
  • See plans for: businesses photographers students
  • Document Cloud
  • Acrobat DC
  • eSign
  • Stock
  • Elements
  • Marketing Cloud
  • Analytics
  • Audience Manager
  • Campaign
  • Experience Manager
  • Media Optimizer
  • Target
  • See all
  • Acrobat Reader DC
  • Adobe Flash Player
  • Adobe AIR
  • Adobe Shockwave Player
  • All products
  • Creative Cloud
  • Individuals
  • Photographers
  • Students and Teachers
  • Business
  • Schools and Universities
  • Marketing Cloud
  • Document Cloud
  • Stock
  • Elements
  • All products
  • Get Support
    Find answers quickly. Contact us if you need to.
    Start now >
  • Learn the apps
    Get started or learn new ways to work.
    Learn now >
  • Ask the community
    Post questions and get answers from experts.
    Start now >
    • About Us
    • Careers At Adobe
    • Investor Relations
    • Privacy  |  Security
    • Corporate Responsibility
    • Customer Showcase
    • Events
    • Contact Us
News
    • 3/22/2016
      Adobe Summit 2016: Are You An Experience Business?
    • 3/22/2016
      Adobe Announces Cross-Device Co-op to Enable People-Based Marketing
    • 3/22/2016
      Adobe and comScore Advance Digital TV and Ad Measurement
    • 3/22/2016
      Adobe Marketing Cloud Redefines TV Experience
CFML Reference / 

ftp

Adobe Community Help


Applies to

  • ColdFusion

Contact support

 
By clicking Submit, you accept the Adobe Terms of Use.
 

Description

Used to implement File Transfer Protocol (FTP) operations using CFScript.

Syntax

Mode

Syntax

Creating the service

new ftp() or createObject("component","ftp")

Initializing the attributes

Any one of the following:

  • ftpService=new ftp(attribute-value pair)
  • ftpService.setAttributes(_attribute-value pair_)
  • ftpService.setA_ttributeName_(attribute_value)
  • ftpService.action_method(attribute-value_pair)

Executing the service action

ftpService.action_method(attribute-value_pair)

Properties

actionparam

buffersize

connection

passive

password

port

proxyserver

retrycount

server

stoponerror

timeout

username

fingerprint

key

passphrase

secure

ASCIIExtensionList

directory

existing

failifexists

item

localfile

name

new

remotefile

result

transfermode

allosize

All attributes supported by the tag cfftp can be used as attribute-value pairs. For example,

<cfftp userName="myUserName">

can be used as

ftpService.setUserName("myUserName");

For details, see the Attributes section for the cfftp tag.

See also

cfftp, Function summary

History

ColdFusion 9: Added this function.

Methods

The following FTP actions are available as methods. All methods have similar arguments and syntax.

  •  

    open

    close

    quote

    site

    allo

    acct

    changeDir

    createDir

    listDir

    removeDir

    getFile

    putFile

    rename

    remove

    getCurrentDir

    getCurrentUrl

    existDir

    existsFile

    exists

     

     

  •  

    Description

    All methods correspond to the FTP actions supported by the tag cfftp. For details of each method, refer to the relevant section for the tag cfftp.

    Returns

    All methods return a component with the following properties set:

     

  • prefix: Equivalent to the result attribute or cfftp scope
  • result: Applicable only for action="listdir"

    Syntax

    ftpService.methodName(attribute-value pair)

    Arguments

    All attributes supported by the tag cfftp.

     

  • setAttributes

    Description

    Sets attributes for the ftp function.

    Returns

    Nothing

    Syntax

    ftpService.setAttributes (attribute-value pair)

    Arguments

    All attributes supported by the tag cfftp.

     

  • getAttributes

    Description

    Gets the attributes that were set for the ftp function.

    Returns

    Returns a struct with all or some attribute values.

    Syntax

    ftpService.get_Attributes_ (attributelist)

    Arguments

    A comma-separated list of attributes. If no list is specified, all defined attributes are returned.

     

  • clear

    Description

    Removes all attributes added for the ftp function.

    Returns

    Nothing

    Syntax

    ftpService.clear()

    Arguments

    None

     

Usage

This function corresponds to the cfftp tag. For details, see the Usage section for the tag cfftp.

Example

<cfscript>
/* Create a new ftp Service*/
ftpService = new ftp();
/* Set attributes using implicit setters */
ftpService.setUsername("myUsername");
ftpService.setPassword("myPassword");
ftpService.setServer("myFtpServer");
ftpService.setStopOnError("true");
ftpService.setConnection("conn");
/* Open connection to ftp server */
WriteOutput("<h4>Open a connection</h4>");
result = ftpService.open();
WriteOutput("<p>Did it succeed? " & result.getPrefix().succeeded & "<br></p>");
/* Get current directory */
WriteOutput("<h4>Get current directory</h4>");
result = ftpService.getcurrentdir();
WriteOutput("<p>Current Directory: " & "'" & result.getPrefix().returnvalue & "'" & "<br></p>");
/* List contents of the current directory */
WriteOutput("<h4>List directory contents</h4>");
result = ftpService.listdir(directory = "/",name="listDirs");
displayListing(result.getResult());
/* Move a file to the ftp server */
WriteOutput("<h4>Move File to Remote Server</h4>");
lFile = "C:\temp\artifacts.xml";
rFile = "artifacts.xml";
result = ftpService.putFile(transferMode="binary", localfile=lFile, remoteFile=rFile);
WriteOutput("<p>Did it succeed? " & result.getPrefix().succeeded & "<br></p>");
/* Close connection to the ftp server */
WriteOutput("<h4>Close the connection</h4>");
ftpService.close(connection="conn");
WriteOutput("<p>Did it succeed? " & result.getPrefix().succeeded & "<br></p>");
</cfscript>
<cffunction name="displayListing" hint="display ftp files">
<cfargument name="filesToList" required="true">
<cftable query = "filesToList" HTMLTable = "Yes" colHeaders = "Yes" border="1" maxrows="10">
<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>
</cffunction>

 

This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License  Twitter™ and Facebook posts are not covered under the terms of Creative Commons.

Legal Notices   |   Online Privacy Policy

Choose your region United States (Change)   Products   Downloads   Learn & Support   Company
Choose your region Close

Americas

Europe, Middle East and Africa

Asia Pacific

  • Brasil
  • Canada - English
  • Canada - Français
  • Latinoamérica
  • México
  • United States
  • Africa - English
  • Österreich - Deutsch
  • Belgium - English
  • Belgique - Français
  • België - Nederlands
  • България
  • Hrvatska
  • Cyprus - English
  • Česká republika
  • Danmark
  • Eesti
  • Suomi
  • France
  • Deutschland
  • Greece - English
  • Magyarország
  • Ireland
  • Israel - English
  • ישראל - עברית
  • Italia
  • Latvija
  • Lietuva
  • Luxembourg - Deutsch
  • Luxembourg - English
  • Luxembourg - Français
  • Malta - English
  • الشرق الأوسط وشمال أفريقيا - اللغة العربية
  • Middle East and North Africa - English
  • Moyen-Orient et Afrique du Nord - Français
  • Nederland
  • Norge
  • Polska
  • Portugal
  • România
  • Россия
  • Srbija
  • Slovensko
  • Slovenija
  • España
  • Sverige
  • Schweiz - Deutsch
  • Suisse - Français
  • Svizzera - Italiano
  • Türkiye
  • Україна
  • United Kingdom
  • Australia
  • 中国
  • 中國香港特別行政區
  • Hong Kong S.A.R. of China
  • India - English
  • 日本
  • 한국
  • New Zealand
  • Southeast Asia (Includes Indonesia, Malaysia, Philippines, Singapore, Thailand, and Vietnam) - English
  • 台灣

Commonwealth of Independent States

  • Includes Armenia, Azerbaijan, Belarus, Georgia, Moldova, Kazakhstan, Kyrgyzstan, Tajikistan, Turkmenistan, Ukraine, Uzbekistan

Copyright © 2016 Adobe Systems Incorporated. All rights reserved.

Terms of Use | Privacy | Cookies

AdChoices