GetRootPath()
Last updated October 03, 2002
Version: 1 | Requires: CF5 | Library: UtilityLib
Description:
It's pretty common to need to root path of an application (for redirects, images, etc.) Typically, this value is hard-coded. This UDF allows you to dynamically determine the root path. Note: this requires that the template calling this UDF is in the root directory.
Return Values:
Returns a string.
Example:
<cfoutput>#getRootPath()#</cfoutput>
Parameters:
No arguments.
Full UDF Source:
/**
* Determines the root path of the application without hard-coding.
*
* @return Returns a string.
* @author Billy Cravens (billy@architechx.com)
* @version 1, October 3, 2002
*/
function GetRootPath() {
var cNested = listLen(getBaseTemplatePath(),"\") - listLen(getCurrentTemplatePath(),"\");
var appRootDir = cgi.script_name;
var i = 0;
for (i=0;i lte cNested;i=incrementValue(i)) {
appRootDir = listDeleteAt(appRootDir,listLen(appRootDir, "/"),"/");
}
appRootDir = appRootDir & "/";
return appRootDir;
}
Search CFLib.org
Latest Additions
Raymond Camden added
QueryDeleteRows
November 04, 2017
Leigh added
nullPad
May 11, 2016
Raymond Camden added
stripHTML
May 10, 2016
Kevin Cotton added
date2ExcelDate
May 05, 2016
Raymond Camden added
CapFirst
April 25, 2016