Oct 2009 30

Occasionally you’ll run into little gotchas when programming in any language.  This one is a frustrating one for many people, but luckily the solution is very simple and doesn’t require anybody else.

If you find yourself using CFDIRECTORY to get the contents of a folder on the server hard drive, sometimes you will run into a situation where you know that you are pointing at the right folder, but the recordcount is zero.  More than likely that is because the CF server doesn’t have the proper permissions to access that folder.  It knows that it is there, but it won’t have access to the files contained therein.

If you don’t necessarily have access to change those file permissions and you don’t want to wait for somebody that does to help out, the easiest solutions is: use ColdFusion to create that folder to begin with.

<cfdirectory action="create" directory="H:\folder\structure\" mode="777">

Once Coldfusion creates that folder, CFDIRECTORY will return the files in that folder since it belongs to the user CF server was installed with.  (The “mode” attribute is only important if you are on a *nix server – that sets the permissions for ‘all’ to read/write/execute.  If you don’t set this you won’t be able to add/delete files from that folder yourself.)

Then remove that line and continue!

Pass this on:
  • Facebook
  • StumbleUpon
  • Digg
  • Reddit
  • TwitThis
  • del.icio.us
  • Google Bookmarks
  • MySpace

Speak your mind