• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

How to display a blob image

New Here ,
Dec 19, 2006 Dec 19, 2006

Copy link to clipboard

Copied

Hi, right now I am calling a stored procedure that returns a blob (JPEG image), what is the easiest way to display this image? I have to somehow use the tobinary function, but I don't seem to generate it correctly? Can someone provide sample code?

Currently, I have something like:
<cfloop query="photoGallery"><img src="toBinary(photoGallery.photo)" width="128" height="180" border="0"></cfloop>

Thanks so much,
C.
TOPICS
Advanced techniques

Views

733

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Dec 19, 2006 Dec 19, 2006

Copy link to clipboard

Copied

Hi C.
I have been using one technique in the past. Once you have that binary data, you need to actually stream it to a file and deliver it via cfcontent.
What I usually do is create a template called dynaimage.cfm
In that template I would get the blob, write to a temp file (in binary), then deliver it via cfcontent with delete=yes to clean it up. Or keep it for caching purposes.

Let me know if this helps.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Dec 19, 2006 Dec 19, 2006

Copy link to clipboard

Copied

Hi Luis, thank you for your reply. I'm a beginner in coldfusion, and I'm wondering about the details of your solution. I know how to get the blob, but how do I 'write' to a temp file in binary, do I use something like cffile action = write and afterwards, I call that file in cfcontent. Is it possible that you have any sample code?

Thanks,
C

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Dec 20, 2006 Dec 20, 2006

Copy link to clipboard

Copied

Hey C,

yep, a simple cffile write, however on the output argument you use:

output="#toBinary(blob)#"

Then you can use the cfcontent tag.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Dec 20, 2006 Dec 20, 2006

Copy link to clipboard

Copied

Thanks Luis, I will work at this.

Thanks again,
C

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Dec 21, 2006 Dec 21, 2006

Copy link to clipboard

Copied

One note about CFFILE is that it automatically appends a CRLF I believe.
This may render the image unusable by the browser.


coldfuse228 wrote:
> Thanks Luis, I will work at this.
>
> Thanks again,
> C

--

Don Vaillancourt
Director of Software Development
WEB IMPACT INC.
phone: 416-815-2000 ext. 245
fax: 416-815-2001
toll free: 866-319-1573 ext. 245
email: donv@web-impact.com <mailto:donv@webimpact.com>
blackberry: donv@rogers.blackberry.net <mailto:donv@rogers.blackberry.net>
web: http://www.web-impact.com
address: http://maps.google.com
< http://maps.google.com/maps?f=q&hl=en&q=99+atlantic+ave,+toronto&ie=UTF8&z=15&ll=43.640765,-79.42076...


This email message is intended only for the addressee(s) and contains
information that may be confidential and/or copyright.

If you are not the intended recipient please notify the sender by reply
email and immediately delete this email.

Use, disclosure or reproduction of this email by anyone other than the
intended recipient(s) is strictly prohibited. No representation is made
that this email or any attachments are free of viruses. Virus scanning
is recommended and is the responsibility of the recipient.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Dec 22, 2006 Dec 22, 2006

Copy link to clipboard

Copied

Hi Don, thank you for your comment, I will keep this in mind,

C

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Dec 22, 2006 Dec 22, 2006

Copy link to clipboard

Copied

Hi, I'll probably post this in a new question. I have an additional comment, I am able to get blob from database and display it on form. However, how can I submit this form including my blob to my action page. I tried using a hidden field on my form to hold the blob like so:

<cfset FaceImg = toString(toBinary(FaceImg.BLOB))>
<cfinput type="hidden" name="FaceImg" value="#FaceImg#">

But for some reason, on the action page, it cannot see it.

Thanks so much,
C

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Dec 22, 2006 Dec 22, 2006

Copy link to clipboard

Copied

Hmm, C.

I don't know why you would want to do that? Any specific reason?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Dec 22, 2006 Dec 22, 2006

Copy link to clipboard

Copied

LATEST
Hi Luis, what I want to do is save the binary data to the database. Basically, this is how my program goes: 1. I display image 2. User click's "Save Image" and then my form submits to an action page that saves Image to my personal database. When user is at the form, he or she already has access to the blob so I was just wondering how I can get this blob to the action page so that I can save it to my db?

Thanks,
C

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation