I won't get into a religous war over storing images/binaries in a DB,
but we have not had any problems and the single source of data is very
efficient. That said...
This is how we are retrieving jpg images from our ID card database. You
may be able to tweak it to fit your needs. Mind your content types.
The code is used as the SRC to an IMG tag.
Example: <img src="image.cfm?id=123">
<cfsetting enablecfoutputonly="Yes">
<cfquery name="q" datasource="dsn">
SELECT
Photo
FROM
IDCards
WHERE
id = <cfqueryparam cfsqltype="CF_SQL_VARCHAR" value="#URL.id#">
</cfquery>
<cfif not isBinary(q.photo)>
<cftry>
<cffile action="readbinary"
file="#expandPath(".")#/ImageNotFound.gif" variable="spacerImage">
<cfcontent type="image/gif">
<cfoutput>#toString(spacerImage)#</cfoutput>
<cfabort>
<cfcatch type="any">
<cfabort>
</cfcatch>
</cftry>
</cfif>
<cfheader name="content-length" value="#arrayLen(q.photo)#">
<cfcontent type="image/jpg">
<cfoutput>#ToString(q.Photo)#</cfoutput>
Thanks,
Mike
-----Original Message-----
From: Priya Koya [mailto:[email protected]]
Sent: Friday, February 27, 2009 9:54 AM
To: cf-talk
Subject: Re: Convert Image to Binary
Now I can sucessfully store the Binary data to thedatabase but unable to
retreive it. Again it is giving me with the same error.
I used <cfcontent> but sometimes its display and sometimes its not. Also
tried sing toString,tobase64 etc.... but no results.
Any ideas....?
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to
date
Get the Free Trial
http://ad.doubleclick.net/clk;207172674;29440083;f
Archive:
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:319907
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe:
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4