Whatever message this page gives is out now! Go check it out!
<head> <title>FTP Test</title> </head> <body> <h1>FTP Test</h1> <!--- Open ftp connection ---> <cfftp connection="Myftp" server="MyServer" username="MyUserName" password="MyPassword" action="Open" stoponerror="Yes"> <!--- Get the current directory name. ---> <cfftp connection=Myftp action="GetCurrentDir" stoponerror="Yes"> <!--- output directory name ---> <cfoutput> The current directory is:#cfftp.returnvalue#<p> </cfoutput> <!--- Get a listing of the directory. ---> <cfftp connection=Myftp action="listdir" directory="#cfftp.returnvalue#" name="dirlist" stoponerror="Yes"> <!--- Close the connection.---> <cfftp action="close" connection="Myftp"> <p>Did the connection close successfully? <cfoutput>#cfftp.succeeded#</cfoutput></p> <!--- output dirlist results ---> <hr> <p>FTP Directory Listing:</p> <cftable query="dirlist" colheaders="yes" 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="#DateFormat(lastmodified)#"> <cfcol header="<B>IsDirectory</b>" TEXT="#isdirectory#"> </cftable> |
Code | Description | |
| Open an FTP connection to the MyServer server and log on as MyUserName. If an error occurs, stop processing and display an error. You can use this connection in other cfftp tags by specifying the Myftp connection. | |
| Use the Myftp connection to get the name of the current directory; stop processing if an error occurs. Display the current directory. | |
| Use the Myftp connection to get a directory listing. Use the value returned by the last cfftp call (the current directory of the connection) to specify the directory to list. Save the results in a variable named dirlist (a query object). Stop processing if an error occurs. | |
| Close the connection, and do not stop processing if the operation fails (because you can still use the results). Instead, display the value of the cfftp.succeeded variable, which is Yes if the connection is closed, and No if the operation failed. | |
| Display a table with the results of the ListDir FTP command. |
<cfftp action="Open" username="anonymous" password="me@home.com" server="ftp.eclipse.com" connection="Session.myconnection"> </cflock> |
Action | Attributes | Action | Attributes |
Open | none | Rename | existingnew |
Close | none | Remove | serveritem |
ChangeDir | directory | GetCurrentDir | none |
CreateDir | directory | GetCurrentURL | none |
ListDir | namedirectory | ExistsDir | directory |
RemoveDir | directory | ExistsFile | remotefile |
GetFile | localfileremotefile | Exists | item |
PutFile | localfileremotefile |