User Guide
120 Chapter 2: ColdFusion Tags
Usage
The following example creates a variable named Message for the contents of the file message.txt:
<cffile action = "read"
file = "c:\web\message.txt"
variable = "Message">
The variable Message can be used in the page. For example, you could display the contents of the
message.txt file in the final web page as follows:
<cfoutput>#Message#</cfoutput>
ColdFusion supports functions for manipulating the contents of text files. You can also use the
variable that is created by a
cffile action = "read" operation in the ArrayToList and
ListToArray functions.
Note: If you use this tag to read a file that is encoded using the Windows Cp1252 (windows-1252)
encoding of the Latin-1 character set on a system whose default character encoding is Cp1252, and
the files has characters encoded in the Hex 8x or 9x range, you must specify
charset="windows-1252" attribute, even though this is the default encoding. Otherwise, some
characters in the Hex8x and 9x ranges that do not map correctly and display incorrectly.