<html>
<head>
<link href="mmres://user_interface_reference.css" rel="stylesheet" type="text/css">
<title>CFFILE ACTION = &QUOT;WRITE&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;WRITE&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>
Writes a text file on the server, based on dynamic content. You can create static HTML files from the content, or log actions in a text file. 
</p>
  <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;write&quot; 
   file = &quot;full_path_name&quot;
   output = &quot;content&quot;
   mode = &quot;permission&quot;
   addNewLine = &quot;yes&quot; or &quot;no&quot;
   attributes = &quot;file_attributes_list&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">Example</span>
<p>
This example creates a file with information a user entered in an HTML insert form: 
</p>
<pre>&lt;cffile action = &quot;write&quot; 
   file = &quot;c:\files\updates\#Form.UpdateTitle#.txt&quot; 
   output = &quot;Created By: #Form.FullName# 
   Date: #Form.Date# 
   #Form.Content#&quot;&gt;
</pre>
<p>
If the user submitted a form with the following:
</p>
<pre>UpdateTitle = &quot;FieldWork&quot;
FullName = &quot;World B. Frueh&quot; 
Date = &quot;10/30/01&quot; 
Content = &quot;We had a wonderful time in Cambridgeport.&quot; 
</pre>
<p>
ColdFusion would create a file named FieldWork.txt in the c:\files\updates\ directory and the file would contain the following text: 
</p>
<pre>Created By: World B. Frueh
Date: 10/30/01 
We had a wonderful time in Cambridgeport.
</pre>
<p>
This example shows the use of the mode attribute for UNIX. It creates the file /tmp/foo with permissions rw-r--r-- (owner = read/write, group = read, other = read): 
</p>
<pre>&lt;cffile action = &quot;write&quot;
   file = &quot;/tmp/foo&quot; 
mode = 644&gt; 
</pre>
<p>
This example appends to the file and sets permissions to read/write (rw) for all:
</p>
<pre>&lt;cffile action = &quot;append&quot;
   destination = &quot;/home/tomj/testing.txt&quot; 
mode = 666 
output = &quot;Is this a test?&quot;&gt;
</pre>
<p>
This example uploads a file and gives it the permissions owner/group/other = read/write/execute):
</p>
<pre>cffile action = &quot;upload&quot;
   fileField = &quot;fieldname&quot; 
destination = &quot;/tmp/program.exe&quot; 
mode = 777&gt;
</pre>
<p>
This example uses the fixnewline attribute to changes embedded line-ending characters in xmlString, which is derived from xmlData, to operating-system specific line endings.
</p>
<pre>&lt;cfxml variable=&quot;xmlData&quot;&gt;
   &lt;docroot&gt;
      &lt;payload type=&quot;string&quot;&gt;This is some plain text&lt;/payload&gt;
   &lt;/docroot&gt;
&lt;/cfxml&gt;
&lt;cfset xmlString = toString(xmlData)&gt;

&lt;cfset key = createUUID()&gt;
&lt;cfset encString=encrypt(xmlString, key)&gt;
&lt;cffile action=&quot;write&quot; addnewline=&quot;yes&quot; 
file=&quot;C:\CFusionMX7\wwwroot\test\store.dat&quot; output=&quot;#encString#&quot; 
fixnewline=&quot;yes&quot;&gt;
&lt;cffile action=&quot;read&quot; file=&quot;C:\CFusionMX7\wwwroot\test\store.dat&quot; 
variable=&quot;retrievedString&quot;&gt;
&lt;cfset decString=decrypt(retrievedString, key)&gt;
&lt;cfdump var=&quot;#decString#&quot;&gt;
&lt;cfset newXML = xmlParse(decString)&gt;
&lt;cfdump var=&quot;#newXML#&quot;&gt;
</pre>
         </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 write. </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="OUTPUT">
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tr>  
<td valign="top" class="name">OUTPUT</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>Content of the file to be created.</p>

  </td>
  </tr>
  </table>
</div>
<div id="MODE">
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tr>  
<td valign="top" class="name">MODE</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">



<p>Applies only to UNIX and Linux. Permissions. Octal values of UNIX chmod command. Assigned to owner, group, and other, respectively. For example:</p><ul>

<li>644: assigns read/write permission to owner; read permission to group and other.</li>

<li>777: assigns read/write/execute permission to all.</li>
</ul>


  </td>
  </tr>
  </table>
</div>
<div id="ADDNEWLINE">
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tr>  
<td valign="top" class="name">ADDNEWLINE</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> "yes"

<ul>

<li>yes: appends newline character to text written to file.</li>

<li>no</li>
</ul>


  </td>
  </tr>
  </table>
</div>
<div id="ATTRIBUTES">
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tr>  
<td valign="top" class="name">ATTRIBUTES</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">



<p>Applies to Windows. A comma-delimited list of attributes to set on the file.</p>
<p>If omitted, the file&#39;s attributes are maintained.</p>
<p>Each value must be specified explicitly. For example, if you specify attributes = &quot;readOnly&quot;, all other attributes are overwritten. </p><ul>

<li>readOnly</li>

<li>hidden</li>

<li>normal</li>
</ul>


  </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> "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>For more information character encodings, see www.w3.org/International/O-charset.html</a>.</p>

  </td>
  </tr>
  </table>
</div>
<div id="FIXNEWLINE">
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tr>  
<td valign="top" class="name">FIXNEWLINE</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> "No"

<ul>

<li>Yes: changes embedded line-ending characters in string variables to operating-system specific line endings.</li>

<li>No: (default) do not change embedded line-ending characters in string variables.</li>
</ul>


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

  </body>
</html>
