How are you storing the image in the db? As binary or string? Either way
cfcontent needs a file, so take query.test, write to file and then read the
file back as action=readbinary then use that var in the cfoutput.

Some code I use

<cfquery name="getBinaryData" datasource="#dsn#">
SELECT binaryString, dataExtension
FROM binaryData
WHERE objectID = #url.objectID#
AND uuid = '#url.uuid#'
</cfquery>

<cfset path = "d:\temp\">

<cfset thisfilename = path & "id_" & url.objectID & "-" & url.uuid & "." &
getBinaryData.dataExtension >

<cfset tobin = tobinary(getBinaryData.binaryString)>

<cfif fileexists(thisfilename)>
<cffile action="DELETE" file="#thisfilename#">
</cfif>
<cffile action="WRITE" file="#thisfilename#" output="#tobin#"
addnewline="No">

<cfset contenttype = "image/" & getBinaryData.dataExtension >

<cfcontent file="#thisfilename#" type="#contenttype#">


I store the image as base64 encoded text in a text column in the db. On the
way out I transfer it back to binary. I really would like cf to let me do
this without writing a file to disc, but alas... No dice. Maybe in neo.

Good luck,

Alexander Sicular
Chief Technology Architect
Neurological Institute of New York
Columbia University
as867 [at] columbia {dot} edu


|-----Original Message-----
|From: Andrew Scott [mailto:[EMAIL PROTECTED]] 
|Sent: Thursday, March 14, 2002 8:11 AM
|To: CF-Talk
|Subject: Image and DB Solution needed
|
|
|I have a small problem; I need to pull images out of a DB. Now 
|if I use the following code nothing is appearing.
|
|<cfcontent type="image/GIF" 
|reset="yes"><cfoutput>#query.test#</cfoutput>
|
|Now if I remove the cfoutputs and use the file attribute it 
|will display an image, so my questioning thinks that there is 
|a problem with what I am doing. I could save the image to the 
|dir and create a link that way, but that would mean I would 
|have all these temp files on the server defeating the purpose 
|of pulling it out of the DB.
|
|Can anyone suggest why the above doesn't work, and if it can 
|not be done maybe describe a solution that could work.
|
|Regards
|Andrew
|
|
|
|
______________________________________________________________________
Dedicated Windows 2000 Server
  PIII 800 / 256 MB RAM / 40 GB HD / 20 GB MO/XFER
  Instant Activation � $99/Month � Free Setup
  http://www.pennyhost.com/redirect.cfm?adcode=coldfusiona
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to