Superlative Solutions' HelpDesk Language
 
Home Knowledge Base ColdFusion and Programming Getting physical path to your web root directory
Information
Article ID5
Created On3/13/2008
Modified3/13/2008
Getting physical path to your web root directory
Many tags, such as CFFILE and CFDIRECTORY require you to provide a PHYSICAL path to the target directory or file. To do this, you need to determine your physical directory, and you can do so using the following code:

<cfscript>
    webroot = getDirectoryFromPath(expandPath("/index.cfm"));
</cfscript>

The above code will return something similar to the following:

    d:\domains\yourdomain\wwwroot\

Note that it includes the trailing backslash, which is important.

Then in CFFILE, if you wanted to put a file, let say in your "uploads" directory, you would use the variable as a prefix for you filename like:

    file="#webroot#uploads/thisfile.jpg"