FileReadBinary

Description

Reads an on-disk or in-memory 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 by using the ToBase64 function.

Note: 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.

Returns

The entire contents of a binary file.

Function syntax

FileReadBinary(filepath)

History

ColdFusion 8: Added this function.

Parameters

Parameter

Description

filepath

An absolute path to an on-disk or in-memory binary file on the server

Usage

You convert the binary file to Base64 to transfer it to another site. ColdFusion 8 supports reading an image file as a binary and passing the result to a cfimage.

Example

The following example reads a binary file.

<h3>FileReadBinary Example</h3> 
<cfscript> 
myfile = FileReadBinary("c:\testingdir\test3.jpg"); 
</cfscript>