Stream images in ColdFusion
You can stream images in Adobe ColdFusion by following the steps below.
- In your main cfm file, add the following line:
<img href="image.cfm">
- Create a new file named "image.cfm" and put in the following code:
Note: You can change the image name and file path on the first line below, or you could also use.
Solution A: If you cannot use cfcontent
<cffile action="readbinary" variable="pic"/>
Solution B: If you can use cfcontent
<cfscript>
context = getPageContext();
context.setFlushOutput(false);
response = context.getResponse().getResponse();
out = response.getOutputStream();
response.setContentType("image/jpeg");
response.setContentLength(arrayLen(pic));
out.write(pic);
out.flush();
// response.reset(); -optional for problems out.close();
</cfscript>
<cfcontent type = "image/jpeg" file = "#ExpandPath('huge.jpg')" deleteFile = "No" reset="yes">
This content requires Flash
To view this content, JavaScript must be enabled, and you need the latest version of the Adobe Flash Player.
Download the free Flash Player now!
