In CFML, there are two functions for accessing a script path:
getBaseTemplatePath() getCurrentTemplatePath()
The getBaseTemplatePath call returns the path of the "base" script - that is, the one requested by the web server.
The getCurrentTemplatePath call returns the path to the current script â that is, the currently executing one.
Both paths are absolute and contain the full directory + script file name.
To determine only the directory, use the getDirectoryFromPath( ... ) function for the results.
So, to determine the location of the application directory, you can do:
<cfset Application.Paths.Root = getDirectoryFromPath( getCurrentTemplatePath() ) />
Inside the onApplicationStart event for your Application.cfc
To determine the path that the application server is running on which your CFML module is running, you can access shell commands using cfexecute, therefore (referring to the above discussion on pwd / etc), you can do:
Unix:
<cfexecute name="pwd"/>
For Windows, create pwd.bat containing the text @cd , and then:
<cfexecute name="C:\docume~1\myuser\pwd.bat"/>
(Use the variable cfexecute attribute to save the value instead of displaying it.)
Peter Boughton Dec 14 '08 at 22:33 2008-12-14 22:33
source share