Although I’ve used ColdFusion for 7+ years now, I’ve never used the cfftp tag before. Yesterday, I found a reason to try it out. I figured it would be as simple as cfhttp–and it was, with one exception (no pun intended).
Here is my sample code:
<cfftp action="open" connection="test" server="ftp.osric.com" username="chris" password="********************" timeout="60" stoponerror="yes"> <cfftp connection = "test" action = "getFile" name = "downloadFile" transferMode = "binary" localFile = "S:\chris\handlebar-moustache.jpg" remoteFile = "handlebar-moustache.jpg" timeout="60">
Here’s the error message it produced:
An error occurred during the FTP getFile operation.
Error: getFile operation exceeded timeout.
However, the local file was still created (as a zero-byte file).
The solution, in my case, was to turn on passive mode (add attribute
passive="yes" to the cfftp tag).
Active FTP vs. Passive FTP, a Definitive Explanation has a brief explanation of the differences between active and passive FTP.