<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>CFFTP: FTP サーバー接続の確立と切断</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">CFFTP: FTP サーバー接続の確立と切断</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>
FTP サーバーとの接続を確立するには、connection 属性に open アクションを指定します。 
</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;cfftp
   action = &quot;action&quot;
   username = &quot;name&quot;
   password = &quot;password&quot;
   server = &quot;server&quot;
   timeout = &quot;timeout in seconds&quot;
   port = &quot;port&quot;
   connection = &quot;name&quot;
   proxyServer = &quot;proxy server&quot;
   retryCount = &quot;number&quot;
   stopOnError = &quot;yes&quot;、&quot;no&quot;
   passive = &quot;yes&quot;、&quot;no&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>
cfhttp、cfldap、cfmail、cfpop
</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>
cfftp action=&quot;open&quot; で接続を確立するときに connection 属性に名前を指定しておくと、他の FTP オペレーションを実行するときにその接続を再使用できるように、接続がキャッシュされます。キャッシュされた接続を後続の FTP オペレーションで使用する場合、username、password、server といった接続属性を指定する必要はありません。同じ connection 名を使用する FTP オペレーションは、キャッシュされた接続に保管されている情報を自動的に使用します。キャッシュされた接続を使用すると、接続時間を節約し、ファイル転送のパフォーマンスを向上させることができます。 
</p>

<p>
1 つの単純な FTP オペレーション (GetFile や PutFile など) を行うたびに接続を開く必要はありません。
</p>

<p>
セッションの間またはセッション後も接続を開いたままにするには、その接続名を Session スコープまたは Application スコープに挿入します。たとえば、connection=&quot;Session.FTPConnection&quot; を指定します。ただし、この方法を使う場合は、すべての FTP オペレーションで完全な変数名を指定し、終了時に close アクションを使用する必要があります。接続を開いたままにしておくと、他のユーザーが FTP サーバーを使用できません。このため、接続はできるだけ早く閉じるようにしてください。接続名をセッション変数またはアプリケーション変数に割り当てなかった場合は、接続を現在のページのためだけに開いたままになるので、手動で閉じる必要はなくなります。 
</p>

<p>
キャッシュされている接続を変更するときには (retryCount 値や timeout 値を変更する場合など)、接続の再確立が必要になることがあります。 
</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><pre>&lt;p&gt;cfftp を使用すると、FTP (File Transfer Protocol: ファイル転送プロトコル) オペレーションの実装が
可能になります。 
デフォルトでは、cfftp を使用すると、開いている FTP サーバーとの接続がキャッシュされます。
&lt;p&gt;通常、ftp オペレーションには次の 2 種類があります。
&lt;ul&gt;
   &lt;li&gt;接続の確立
   &lt;li&gt;ファイルとディレクトリのオペレーション
&lt;/ul&gt;
&lt;p&gt;この例では、接続を開いて検証し、ディレクトリ内のファイルをリストして、接続を閉じます。
&lt;p&gt;接続を開きます。
&lt;cfftp action = &quot;open&quot;
   username = &quot;anonymous&quot;
   connection = &quot;My_query&quot;
   password = &quot;youremail@email.com&quot;
   server = &quot;ftp.tucows.com&quot;
   stopOnError = &quot;Yes&quot;&gt;
&lt;p&gt;成功しましたか? &lt;cfoutput&gt;#cfftp.succeeded#&lt;/cfoutput&gt;
&lt;p&gt;ディレクトリ内のファイルをリストします。
&lt;cfftp action = &quot;LISTDIR&quot;
    stopOnError = &quot;Yes&quot;
    name = &quot;ListFiles&quot;
    directory = &quot;/&quot;
    connection = &quot;my_query&quot;&gt;
&lt;cfoutput query = &quot;ListFiles&quot;&gt;
   #name#&lt;br&gt;
&lt;/cfoutput&gt;

&lt;p&gt;接続を閉じます。
&lt;cfftp action = &quot;close&quot;
connection = &quot;My_query&quot;
stopOnError = &quot;Yes&quot;&gt;
&lt;p&gt;成功しましたか? &lt;cfoutput&gt;#cfftp.succeeded#&lt;/cfoutput&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>実行する FTP オペレーションです。 </p><ul>

<li>open: FTP 接続を確立します。</li>

<li>close: FTP 接続を終了します。</li>
</ul>


  </td>
  </tr>
  </table>
</div>
<div id="USERNAME">
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tr>  
<td valign="top" class="name">USERNAME</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">action = &quot;open&quot; の場合は必須</td>
  </tr>
  <tr>
  <td colspan="2" class="clearseparation">&nbsp;</td>
  </tr>
  <tr>
  <td valign="top" colspan="2" class="description">



<p>FTP オペレーションで渡すユーザー名です。 </p>

  </td>
  </tr>
  </table>
</div>
<div id="PASSWORD">
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tr>  
<td valign="top" class="name">PASSWORD</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">action = &quot;open&quot; の場合は必須</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="SERVER">
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tr>  
<td valign="top" class="name">SERVER</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">action = &quot;open&quot; の場合は必須</td>
  </tr>
  <tr>
  <td colspan="2" class="clearseparation">&nbsp;</td>
  </tr>
  <tr>
  <td valign="top" colspan="2" class="description">



<p>接続先の FTP サーバーです (例 : ftp.myserver.com)。</p>

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


<p>個々のデータリクエストオペレーションなど、すべてのオペレーションに関するタイムアウト値です (単位 : 秒)。 </p>

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


<p>接続先のリモートポートです。 </p>

  </td>
  </tr>
  </table>
</div>
<div id="CONNECTION">
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tr>  
<td valign="top" class="name">CONNECTION</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">オプション (ただし open または close のときは常に使用)</td>
  </tr>
  <tr>
  <td colspan="2" class="clearseparation">&nbsp;</td>
  </tr>
  <tr>
  <td valign="top" colspan="2" class="description">



<p>FTP 接続の名前です。username、password、および server 属性を指定した場合で、対応する接続がないときは、ColdFusion により新しい接続が作成されます。同じ接続名で cfftp を呼び出すと、同じ接続が再利用されます。</p>

  </td>
  </tr>
  </table>
</div>
<div id="PROXYSERVER">
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tr>  
<td valign="top" class="name">PROXYSERVER</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="RETRYCOUNT">
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tr>  
<td valign="top" class="name">RETRYCOUNT</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> "1&#160;"


<p>エラーがレポートされるまでの再試行回数です。 </p>

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

<li>cfftp.succeeded - yes または no。</li>

<li>cfftp.errorCode - エラー番号。IETF Network Working Group RFC 959: File Transfer Protocol (FTP) を参照 (www.ietf.org/rfc/rfc0959.txt</a>)。 </li>

<li>cfftp.errorText - メッセージテキスト。 </li>
</ul>
</ul>

<p>条件付きオペレーションには、cfftp.errorCode を使用します。cfftp.errorText は使用しないでください。</p>

  </td>
  </tr>
  </table>
</div>
<div id="PASSIVE">
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tr>  
<td valign="top" class="name">PASSIVE</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: passive モードを有効にします。</li>

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


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

  </body>
</html>
