Accessibility

TechNote

Stream images in ColdFusion

You can stream images in Adobe ColdFusion by following the steps below.

  1. In your main cfm file, add the following line:

    <img href="image.cfm">

  2. 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"/>
    		

    <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>

    Solution B: If you can use cfcontent
     <cfcontent type = "image/jpeg" file = "#ExpandPath('huge.jpg')" deleteFile = "No" reset="yes">
    		

AlertThis 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!

Get Adobe Flash Player

Creative Commons License

Search Support


Document Details

ID:kb405330

Products Affected:

coldfusion