CFLib.org – Common Function Library Project

GetHTTPDir([pathType])

Last updated October 09, 2001

author

Spike

Version: 1 | Requires: CF5 | 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:

<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:

/**
 * 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,'/'),'/')#/";
    }
}

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

Created by Raymond Camden / Design by Justin Johnson