Posted on July 7, 2009 - by J Lane
CFFTP not returning a directory listing
In my Googling, I couldn’t find anything about it, so I thought I’d post something here. It might seem painfully obvious to most ColdFusion developers, but my brain has been dealing with a head cold, and I just couldn’t figure out what I was doing wrong.
I’m not sure if it’s true of all servers/situations, but I was running into a problem with CFFTP recently. I could connect to an FTP server fine, and get a directory listing of the root folder, but subfolders weren’t returning anything. There wasn’t an error returned, it just returned nothing.
Turns out what I was doing wrong was that you actually need to change into the working directory before listing it’s contents. In retrospect, yeah, it makes sense, but it was something that confused me for an hour or so.
<cfftp connection="myConnection" action="changeDir" directory="/some/sub/folder/"> <cfftp connection="myConnection" action="listDir" directory="/some/sub/folder/">
Seems silly to me that it works this way, especially because you have to specify complete paths in all CFFTP operations. It would be one thing if I just had to specify the complete path in the changeDir operation, and then listDir would just assume I mean the current working directory (the directory attribute would be optional), but it doesn’t work like that. Same deal for getFile and putFile operations… have to specify the complete path.
Not the end of the world, just mildly annoying.

Flyingtroll.com is the personal web site of Jonathan C Lane, a Mayne Island, BC-based web developer, author and all-around great guy.
1 Comment
We'd love to hear yours!