<html>
<head>
<link href="mmres://user_interface_reference.css" rel="stylesheet" type="text/css">
<title>CFFILE ACTION = &QUOT;READBINARY&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;READBINARY&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 binary file (such as an executable or image file) on the server, into a binary object parameter that you can use in the page. To send it through a web protocol (such as HTTP or SMTP) or store it in a database, first convert it to Base64 using the ToBase64 function. 
</p>
<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 they 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;readBinary&quot; 
   file = &quot;full_path_name&quot;
   variable = &quot;var_name&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>

<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>
You convert the binary file to Base64 to transfer it to another site.
</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>
The following example reads the binary file somewhere.jpg, writes it to a different folder as somewhereB.jpg, and then displays the new file:
</p>
<pre>&lt;cffile action = &quot;readBinary&quot; file = 
&quot;C:\inetpub\wwwroot\cfdocs\getting_started\photos\somewhere.jpg&quot; variable = 
&quot;aBinaryObj&quot;&gt;
&lt;!--- Output binary object to JPEG format for viewing. ---&gt;
&lt;cffile action=&quot;write&quot; file = &quot;c:\files\updates\somewhereB.jpg&quot; output = 
&quot;#toBinary(aBinaryObj)#&quot;&gt;
&lt;!--- HTML to view image. ---&gt;
&lt;img src=&quot;C:\files\updates\somewhereB.jpg&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 a binary fine 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 binary file. </p>

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

  </body>
</html>
