Whatever message this page gives is out now! Go check it out!
| Mode | Syntax |
Creating the service | new ftp() or createObject("component","ftp") |
Initializing the attributes | Any one of the following:
|
Executing the service action | ftpService.action_method(attribute-value_pair) |
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 |
<cfftp userName="myUserName"> |
ftpService.setUserName("myUserName"); |
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: |
Syntax | ftpService.methodName(attribute-value pair) |
Arguments | All attributes supported by the tag cfftp. |
Description | Sets attributes for the ftp function. |
Returns | Nothing |
Syntax | ftpService.setAttributes (attribute-value pair) |
Arguments | All attributes supported by the tag cfftp. |
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. |
Description | Removes all attributes added for the ftp function. |
Returns | Nothing |
Syntax | ftpService.clear() |
Arguments | None |
<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> |