How To The Write `<cffile action=”readBinary”>` Function In ColdFusion?
Description:-
It 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.
<cffile
action = "readBinary"
file = "full pathname"
variable = "variable name"
>
cfscript the equivalent of the upper syntax
<cfscript>
cffile(
action = "read",
file = "full pathname",
variable = "variable name"
);
</cfscript>
Attributes:-
action:- This is a required attribute, the type of file manipulation that the tag performs.
file:- This is a required attribute, The pathname of the binary file to which needs to be read.
variable:- This is a required attribute, the Name of the variable to contain the contents of the binary file.
Example:-
The following example creates a variable named testBinary for the contents of the file testNote.jpg:
<cffile
action = "readBinary"
file = "d:\files\documents\testNote.jpg"
variable = "testBinary"
>
The variable testBinary can be used in the page. For example, Create a cfimage from the binary object variable on the final web page as follows:
<cfset myImage=ImageNew(testBinary)>
