CFLib.org – Common Function Library Project

GetHTTPDir([pathType])

Last updated October 9, 2001

Version: 1 | Requires: ColdFusion 5 | Library: FileSysLib

 
Rated 0 time(s). Average Rating: 0

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:

view plain print about
<STRONG>Full Format:</STRONG><BR>
<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:

view plain print about
<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>
blog comments powered by Disqus

Search CFLib.org


Latest Additions

Tayo Akinmade Tayo Akinmade added
arrayTrim
10 day(s) ago

Will Belden Will Belden added
longTime
15 day(s) ago

James Sleeman James Sleeman added
quickSort
25 day(s) ago

Ben Forta Ben Forta added
GetHostAddress
28 day(s) ago

Top Rated

Darwan Leonardo Sitepu EksporSQLData
Rated 5.0, 16 time(s)

Darwan Leonardo Sitepu backupDatabase
Rated 5.0, 13 time(s)

Barney Boisvert indentXml
Rated 5.0, 10 time(s)

Kevin Pepperman generateSsccAsn
Rated 5.0, 4 time(s)

Created by Raymond Camden / Design by Justin Johnson