Skip to main content
Inspiring
January 21, 2009
Answered

How to access a text file located above web root?

  • January 21, 2009
  • 1 reply
  • 439 views
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 has been closed for replies.
    Correct answer craigkaminsky
    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

    1 reply

    craigkaminskyCorrect answer
    Inspiring
    January 21, 2009
    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
    Inspiring
    January 21, 2009
    Thanks. Didn't realize/had forgotten cffile works above web root.