Skip to main content
WolfShade
Legend
March 13, 2017
Answered

BLOB image to browser WITHOUT using CFIMAGE?

  • March 13, 2017
  • 1 reply
  • 1545 views

Hello, all,

I am trying to re-write part of an application that loads images from a database into a carousel.

Currently, the logic grabs the BLOBs from the database, saves them to a folder, and then displays the images.

I'd like to grab the BLOBs and directly display them on the page without saving them to a folder.  However, after all the Google search attempts, I have not found a solution - they all want to use CFIMAGE action="writeToBrowser".

Unfortunately, the directory that these images are saved to with writeToBrowser action is blocked by network admins and the people who control the CF server.  So I _can't_ use CFIMAGE.

Is there a way to take the BLOB images direct from database to browser without using CFIMAGE??

V/r,

^_^

UPDATE: We need to be able to support IE9+, possibly IE8, and FireFox v42+.

    This topic has been closed for replies.
    Correct answer haxtbh

    Its technically supported but the size limit is where the issue will lie. You will have to test it.

    The other option to read the file and then save it to a dir you do have access to then use this to display the image. So save it to /images/ for example and the image src just points to that folder.

    Without access to certain things you will be limited.

    You might be able to do it with cfcontent.

    Use something like:

    <cfcontent reset="Yes" type="image/jpg" variable="#QueryName.BlobColumn#"/>

    This would go in separate page that you pass the required vars you need for the query (i.e. the id). You could save this as getMyImage.cfm then call it from the src of the image you want to show.

    <img src="getMyImage.cfm?queryID=1234">

    Never tried it myself, but could work.

    1 reply

    Inspiring
    March 14, 2017

    You could use BinaryEncode to convert the binary to base64. Then use this base64 in the src of the image.

    There were some limitations with older browsers and base64 images. They could only be so large before the browser didnt load them.

    I would just ask for the temp dir to be unblocked by the admins though ^^

    WolfShade
    WolfShadeAuthor
    Legend
    March 14, 2017

    haxtbh  wrote

    I would just ask for the temp dir to be unblocked by the admins though ^^

    I'm a federal contractor.  The DoD won't even hear me asking.  Not happening.

    Thanks for the suggestions, but will that work with A) IE8 or IE9, and B) with large images (4-8M)?  You're referring to the "data:" method, right?

    V/r,

    ^_^

    haxtbhCorrect answer
    Inspiring
    March 14, 2017

    Its technically supported but the size limit is where the issue will lie. You will have to test it.

    The other option to read the file and then save it to a dir you do have access to then use this to display the image. So save it to /images/ for example and the image src just points to that folder.

    Without access to certain things you will be limited.

    You might be able to do it with cfcontent.

    Use something like:

    <cfcontent reset="Yes" type="image/jpg" variable="#QueryName.BlobColumn#"/>

    This would go in separate page that you pass the required vars you need for the query (i.e. the id). You could save this as getMyImage.cfm then call it from the src of the image you want to show.

    <img src="getMyImage.cfm?queryID=1234">

    Never tried it myself, but could work.