Whatever message this page gives is out now! Go check it out!

FileReadBinary

Last update:
May 18, 2026

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.

Category

Function syntax

FileReadBinary(filepath)

See also

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>

Share this page

Was this page helpful?
We're glad. Tell us how this page helped.
We're sorry. Can you tell us what didn't work for you?
Thank you for your feedback. Your response will help improve this page.

On this page