<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link href="mmres://user_interface_reference.css" rel="stylesheet" type="text/css">
<title>CFFILE ACTION = "WRITE"</title>
</head>
<body bgcolor="#FFFFFF" text="#000000">
   <div id="説明">
   <table cellpadding="0" cellspacing="0" border="0" width="100%" class="main">
      <tr> 
         <td valign="top" class="name">CFFILE ACTION = "WRITE"</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">説明</span>
<p>
ダイナミックコンテンツをベースにして、サーバーにテキストファイルを書き込みます。コンテンツからスタティックな HTML ファイルを作成したり、テキストファイル内にアクションを記録したりできます。 
</p>
  <tr>
    <td valign="top" colspan="2" class="CLEARSEPARATION">&nbsp;</td>
  </tr>
  <tr>
    <td valign="top" colspan="2" class="syntax"><span class="title">シンタックス</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;、&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">関連項目</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">ヒストリ</span>
<p>
メインの cffile タグのページの「ヒストリ」を参照してください。
</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">例</span>
<p>
この例では、ユーザーが HTML 挿入フォームに入力した情報を使用してファイルを作成します。 
</p>
<pre>&lt;cffile action = &quot;write&quot;
   file = &quot;c:filesupdates#Form.UpdateTitle#.txt&quot;
   output = &quot;作成者 :#Form.FullName#
   作成日 :#Form.Date#
   #Form.Content#&quot;&gt;
</pre>
<p>
ユーザーが次のフォームを送信した場合、
</p>
<pre>UpdateTitle = &quot;FieldWork&quot;
FullName = &quot;World B. Frueh&quot;
Date = &quot;10/30/01&quot;
Content = &quot;Cambridgeport で楽しい時間を過ごした。&quot; 
</pre>
<p>
c:filesupdates ディレクトリに FieldWork.txt という名前のファイルが作成され、ファイルに次のテキストが加えられます。 
</p>
<pre>作成者 : World B. Frueh
作成日 : 10/30/01 
Cambridgeport で楽しい時間を過ごした。
</pre>
<p>
この例は、UNIX での mode 属性の使用方法を示しています。ファイル /tmp/foo を作成し、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>
この例では、ファイルへの追加を行い、利用者全員に読み取り/書き込み (rw) 許可を設定します。
</p>
<pre>&lt;cffile action = &quot;append&quot;
   destination = &quot;/home/tomj/testing.txt&quot;
mode = 666 
output = &quot;これはテストですか?&quot;&gt;
</pre>
<p>
この例では、ファイルをアップロードして、アクセス許可を 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>
この例では、fixnewline 属性を使用して、xmlData から派生する xmlString に埋め込まれた行終了文字を、オペレーティングシステム固有の行終了文字に変更します。
</p>
<pre>&lt;cfxml variable=&quot;xmlData&quot;&gt;
   &lt;docroot&gt;
      &lt;payload type=&quot;string&quot;&gt;これはプレーンテキストです。&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:CFusionMX7wwwrootteststore.dat&quot; 
output=&quot;#encString#&quot; fixnewline=&quot;yes&quot;&gt;
&lt;cffile action=&quot;read&quot; file=&quot;C:CFusionMX7wwwrootteststore.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">必須</td>
  </tr>
  <tr>
  <td colspan="2" class="clearseparation">&nbsp;</td>
  </tr>
  <tr>
  <td valign="top" colspan="2" class="description">



<p>このタグが実行するファイル操作のタイプです。 </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">必須</td>
  </tr>
  <tr>
  <td colspan="2" class="clearseparation">&nbsp;</td>
  </tr>
  <tr>
  <td valign="top" colspan="2" class="description">



<p>書き込み先となるファイルのパス名です。 </p>
<p>絶対パス (ドライブ文字とコロン、あるいはスラッシュまたは円記号から始まるパス) を指定しなかった場合は、GetTempDirectory 関数から返される ColdFusion テンポラリディレクトリを基準とする相対パスになります。</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">必須</td>
  </tr>
  <tr>
  <td colspan="2" class="clearseparation">&nbsp;</td>
  </tr>
  <tr>
  <td valign="top" colspan="2" class="description">



<p>作成するファイルの内容です。</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">オプション</td>
  </tr>
  <tr>
  <td colspan="2" class="clearseparation">&nbsp;</td>
  </tr>
  <tr>
  <td valign="top" colspan="2" class="description">



<p>UNIX および Linux だけに適用されます。許可を表す UNIX chmod コマンドの 8 進数値です。所有者、グループ、および他の利用者それぞれに割り当てられます。例 : </p><ul>

<li>644: 所有者に読み取り/書き込み許可、グループおよび他の利用者に読み取り許可を割り当てます。</li>

<li>777: 利用者全員に読み取り/書き込み/実行許可を割り当てます。</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">オプション</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: ファイルに書き込まれるテキストに改行文字を追加します。</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">オプション</td>
  </tr>
  <tr>
  <td colspan="2" class="clearseparation">&nbsp;</td>
  </tr>
  <tr>
  <td valign="top" colspan="2" class="description">



<p>Windows に適用されます。ファイルに設定する属性をカンマ区切りリストで指定します。</p>
<p>この属性を省略した場合、ファイルの属性が保持されます。</p>
<p>値はそれぞれ明示的に指定する必要があります。たとえば、attributes = &quot;readOnly&quot; を指定した場合、他の属性がすべて上書きされます。 </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">オプション</td>
  </tr>
  <tr>
  <td colspan="2" class="clearseparation">&nbsp;</td>
  </tr>
  <tr>
  <td valign="top" colspan="2" class="description">

<strong>Default value:</strong> "JVM のデフォルトのファイル文字セット"


<p>ファイルコンテンツをエンコードする文字エンコードを指定します。一般的に使用される値を次に示します。</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>文字エンコードの詳細については、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">オプション</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: 文字列変数に埋め込まれた行終了文字を、オペレーティングシステム固有の行終了文字に変更します。</li>

<li>No: (デフォルト) 文字列変数に埋め込まれた行終了文字を変更しません。</li>
</ul>


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

  </body>
</html>
