Skip to main content
Inspiring
Jan 21, 2009 8:35 PM UTC
Answered

How to access a text file located above web root?

For security I would like to place a text file with login information above the web root. Currently the file not above the root and it's accessed like this:

<cffile
action="read"
file="path/file.txt"
variable="userList">

followed by

<cfset variables.userList.userArray=listToArray(userList,Chr(10))>.




    This topic is closed to new replies. Start a new post to keep the conversation going.
    craigkaminskyCorrect answer
    Inspiring
    Jan 21, 2009 8:42 PM UTC
    If you know the correct file path, you should be able to simply reference it in the file attribute of CFFILE:

    <cffile action="read" variable="var" file="C:\somedir\someotherdir\yetanotherdir\file.txt" />

    If you need to dynamically figure out the path, you can explore CF functions such as ExpandPath and similar functions in the System Functions category of the online docs for CF 8:
    http://livedocs.adobe.com/coldfusion/8/htmldocs/index.html

    2 replies

    craigkaminskyCorrect answer
    Inspiring
    Jan 21, 2009 8:42 PM UTC
    If you know the correct file path, you should be able to simply reference it in the file attribute of CFFILE:

    <cffile action="read" variable="var" file="C:\somedir\someotherdir\yetanotherdir\file.txt" />

    If you need to dynamically figure out the path, you can explore CF functions such as ExpandPath and similar functions in the System Functions category of the online docs for CF 8:
    http://livedocs.adobe.com/coldfusion/8/htmldocs/index.html
    Translate
    Inspiring
    Jan 21, 2009 9:19 PM UTC
    Thanks. Didn't realize/had forgotten cffile works above web root.
    Translate