GetHTTPDir([pathType])
Last updated October 9, 2001
Version: 1 | Requires: ColdFusion 5 | Library: FileSysLib
Description:
Retrieves the url for the current directory in full or relative format. Depends on cgi.server_name and cgi.script_name variables.
Return Values:
Returns a string.
Example:
<CFOUTPUT>#GetHTTPDir('full')#</CFOUTPUT>
<BR>
<BR>
<STRONG>Relative Format:</STRONG> <BR>
<CFOUTPUT>#GetHTTPDir('relative')#</CFOUTPUT>
<BR>
<BR>
<STRONG>Default Format:</STRONG> <BR>
<CFOUTPUT>#GetHTTPDir()#</CFOUTPUT><BR>
<BR>
<STRONG>Invalid Parameter:</STRONG><BR>
<CFOUTPUT>#GetHTTPDir('part')#</CFOUTPUT>
Parameters:
| Name | Description | Required |
|---|---|---|
| pathType | Format to return the path in. Valid values are 'full' and 'relative'. Returns the text string 'invalid paramter' if the parameter is not 'full' or 'relative'. Default value for the parameter is 'relative'. | No |
Full UDF Source:
<cfscript>
/**
* Retrieves the url for the current directory in full or relative format.
*
* @param pathType Format to return the path in. Valid values are 'full' and 'relative'. Returns the text string 'invalid paramter' if the parameter is not 'full' or 'relative'. Default value for the parameter is 'relative'.
* @return Returns a string.
* @author Spike (spike@spike.org.uk)
* @version 1, October 9, 2001
*/
function GetHTTPDir() {
var format = "";
if (arraylen(arguments)) {
format = arguments[1];
if (format EQ 'full') {
return "http://#cgi.server_name##listDeleteAt(cgi.script_name,listlen(cgi.script_name,'/'),'/')#/";
}
else if (format EQ 'relative') {
return "#listDeleteAt(cgi.script_name,listlen(cgi.script_name,'/'),'/')#/";
}
else {
return 'invalid argument';
}
}
else {
return "#listDeleteAt(cgi.script_name,listlen(cgi.script_name,'/'),'/')#/";
}
}
</cfscript>
Search CFLib.org
Latest Additions
Tayo Akinmade added
arrayTrim
10 day(s) ago
Will Belden added
longTime
15 day(s) ago
James Sleeman added
quickSort
25 day(s) ago
Ben Forta added
GetHostAddress
28 day(s) ago
Top Rated
EksporSQLData
Rated 5.0, 16 time(s)
backupDatabase
Rated 5.0, 13 time(s)
indentXml
Rated 5.0, 10 time(s)
generateSsccAsn
Rated 5.0, 4 time(s)