<html>
<head>
<link href="mmres://user_interface_reference.css" rel="stylesheet" type="text/css">
<title>CFFILE ACTION = &QUOT;READ&QUOT;</title>
</head>
<body bgcolor="#FFFFFF" text="#000000">
   <div id="Description">
   <table cellpadding="0" cellspacing="0" border="0" width="100%" class="main">
      <tr> 
         <td valign="top" class="name">CFFILE ACTION = &QUOT;READ&QUOT;</td>
         <td valign="top" nowrap class="compatibility">&nbsp;</td>
      </tr>
      <tr>
         <td colspan="2" class="divider"><img src="dwres:18084" width="100%" height="1"></td>
      </tr>


    </td>
  </tr>
  <tr>
    <td valign="top" colspan="2" class="description"><span class="title">Description</span>
<p>
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:
</p>
<ul>

<li>Read a text file; insert the file's contents into a database</li>

<li>Read a text file; use the find and replace function to modify the file's contents</li>
</ul>
<table>
  <tr valign="top">
    <td width="30"><strong>Note: </strong></td>
    <td>This action reads the file into a variable in the local Variables scope. It is not intended for use with large files, such as logs, because this can bring down the server.</td>
  </tr>
</table>  <tr>
    <td valign="top" colspan="2" class="CLEARSEPARATION">&nbsp;</td>
  </tr>
  <tr>
    <td valign="top" colspan="2" class="syntax"><span class="title">Syntax</span><pre>&lt;cffile 
   action = &quot;read&quot; 
   file = &quot;full_path_name&quot;
   variable = &quot;var_name&quot;
   charset = &quot;charset_option&quot; &gt;
</pre>    </td>
  </tr>
  <tr>
    <td valign="top" colspan="2" class="CLEARSEPARATION">&nbsp;</td>
  </tr>
  <tr>
    <td valign="top" colspan="2" class="description"><span class="title">See also</span>
<p>
cfdirectory
</p>
    </td>
  </tr>
  <tr>
    <td valign="top" colspan="2" class="CLEARSEPARATION">&nbsp;</td>
  </tr>
  <tr>
    <td valign="top" colspan="2" class="description"><span class="title">History</span>
<p>
See the History section of the main cffile tag page.
</p>

<p>

</p>
    </td>
  </tr>
  <tr>
    <td valign="top" colspan="2" class="CLEARSEPARATION">&nbsp;</td>
  </tr>
  <tr>
    <td valign="top" colspan="2" class="description"><span class="title">Usage</span>
<p>
The following example creates a variable named Message for the contents of the file message.txt:
</p>
<pre>&lt;cffile          action = &quot;read&quot; 
file = &quot;c:\web\message.txt&quot; 
variable = &quot;Message&quot;&gt;
</pre>
<p>
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: 
</p>
<pre>&lt;cfoutput&gt;#Message#&lt;/cfoutput&gt;
</pre>
<p>
ColdFusion supports functions for manipulating the contents of text files. You can also use the variable that is created by a cffile action = &quot;read&quot; operation in the ArrayToList and ListToArray functions. 
</p>
<table>
  <tr valign="top">
    <td width="30"><strong>Note: </strong></td>
    <td>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=&quot;windows-1252&quot; 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.</td>
  </tr>
</table>
         </td>
      </tr>
   </table>
   </div>
<div id="ACTION ">
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tr>  
<td valign="top" class="name">ACTION </td>
  <td valign="top" nowrap class="compatibility">&nbsp;</td>
  </tr>
  <tr>
  <td colspan="2" class="divider"><img src="dwres:18084" width="100%" height="1"></td>
  </tr>

  <tr>
  <td valign="top" class="syntax">&nbsp;</td>
  <td valign="top" nowrap class="requirements">Required</td>
  </tr>
  <tr>
  <td colspan="2" class="clearseparation">&nbsp;</td>
  </tr>
  <tr>
  <td valign="top" colspan="2" class="description">



<p>Type of file manipulation that the tag performs. </p>

  </td>
  </tr>
  </table>
</div>
<div id="FILE">
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tr>  
<td valign="top" class="name">FILE</td>
  <td valign="top" nowrap class="compatibility">&nbsp;</td>
  </tr>
  <tr>
  <td colspan="2" class="divider"><img src="dwres:18084" width="100%" height="1"></td>
  </tr>

  <tr>
  <td valign="top" class="syntax">&nbsp;</td>
  <td valign="top" nowrap class="requirements">Required</td>
  </tr>
  <tr>
  <td colspan="2" class="clearseparation">&nbsp;</td>
  </tr>
  <tr>
  <td valign="top" colspan="2" class="description">



<p>Pathname of the file to read.</p>
<p>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.</p>

  </td>
  </tr>
  </table>
</div>
<div id="VARIABLE">
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tr>  
<td valign="top" class="name">VARIABLE</td>
  <td valign="top" nowrap class="compatibility">&nbsp;</td>
  </tr>
  <tr>
  <td colspan="2" class="divider"><img src="dwres:18084" width="100%" height="1"></td>
  </tr>

  <tr>
  <td valign="top" class="syntax">&nbsp;</td>
  <td valign="top" nowrap class="requirements">Required</td>
  </tr>
  <tr>
  <td colspan="2" class="clearseparation">&nbsp;</td>
  </tr>
  <tr>
  <td valign="top" colspan="2" class="description">



<p>Name of variable to contain contents of text file. </p>

  </td>
  </tr>
  </table>
</div>
<div id="CHARSET">
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tr>  
<td valign="top" class="name">CHARSET</td>
  <td valign="top" nowrap class="compatibility">&nbsp;</td>
  </tr>
  <tr>
  <td colspan="2" class="divider"><img src="dwres:18084" width="100%" height="1"></td>
  </tr>

  <tr>
  <td valign="top" class="syntax">&nbsp;</td>
  <td valign="top" nowrap class="requirements">Optional</td>
  </tr>
  <tr>
  <td colspan="2" class="clearseparation">&nbsp;</td>
  </tr>
  <tr>
  <td valign="top" colspan="2" class="description">

<strong>Default value:</strong> "Character encoding identified by the file's byte order mark, if any; otherwise, JVM default file character set."


<p>The character encoding in which the file contents is encoded. The following list includes commonly used values:</p><ul>

<li>utf-8</li>

<li>iso-8859-1 </li>

<li>windows-1252</li>

<li>us-ascii</li>

<li>shift_jis</li>

<li>iso-2022-jp </li>

<li>euc-jp</li>

<li>euc-kr</li>

<li>big5</li>

<li>euc-cn</li>

<li>utf-16</li>
</ul>

<p>If the file starts with a byte order mark and you set this attribute to a conflicting character encoding, ColdFusion generates an error.</p>
<p>For more information character encodings, see www.w3.org/International/O-charset.html</a>.</p>

  </td>
  </tr>
  </table>
</div>

  </body>
</html>
