Many years ago, I was told "Don't hard code your path" in ColdFusion when reading or writing files to your server.
So, I DID NOT "hard code" my paths. Or so I thought. Sample below of what I considered "hard coded"
<cffile destination="C:\Inetpub\wwwroot\myfiles\">
Instead I used application variables to hard code my paths.
<cffile destination="#application.myfilesPath#">
What a mistake! that i recently had to rectify.
My move to a Mac and setting up a local development environment brought this mistake to a head. I'm running ColdFusion Developer Edition, Apache, Eclipse, and Subversion. Fire up my browser to test out my local.domain.com and noticed that file upload is broken.
Those paths set as application variables work fine on Windows with backslashes, but won't work on my UNIX based Mac which wants /Applications/xampp/xampfiles/htdocs/myfiles
Enter the function I'd used before, but not committed to my daily life.
ExpandPath()
Many ... many ... hours later the site now runs on my mac AND on the windows server.
Point to the webroot #ExpandPath('/')#
Point to the "myfiles" a subdirectory of the webroot #ExpandPath('/myfiles')#
Point to the "otherfiles" not in the webroot #ExpandPath('../otherfiles')#
There are no comments for this entry.
[Add Comment]