CFFILE ACTION = "READ" | ||
Description | ||
Reads a text file on the server. The file is read into a dynamic, local variable that you can use in the page. For example:
| ||
Syntax<cffile action = "read" file = "full_path_name" variable = "var_name" charset = "charset_option" > |
||
See also | ||
cfdirectory | ||
History | ||
See the History section of the main cffile tag page. | ||
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.
|
ACTION | |
Required | |
Type of file manipulation that the tag performs. |
FILE | |
Required | |
Pathname of the file to read. If not an absolute path (starting a with a drive letter and a colon, or a forward or backward slash), it is relative to the ColdFusion temporary directory, which is returned by the GetTempDirectory function. |
VARIABLE | |
Required | |
Name of variable to contain contents of text file. |
CHARSET | |
Optional | |
Default value: "Character encoding identified by the file's byte order mark, if any; otherwise, JVM default file character set."
The character encoding in which the file contents is encoded. The following list includes commonly used values:
If the file starts with a byte order mark and you set this attribute to a conflicting character encoding, ColdFusion generates an error. For more information character encodings, see:www.w3.org/International/O-charset.html. |