I like it!!!
<img src="binary.cfm"> now returns a random image form the db
<cfsetting enablecfoutputonly="yes" showdebugoutput="no">
<cfsilent>
<cfquery name="qGet" datasource="dsnTest_development">
SELECT TOP 1 fileContent
FROM tblImage
ORDER BY NEWID()
</cfquery>
</cfsilent>
<cfcontent type="image/gif; charset=8859_1">
<cfscript>
writeOutput(toString(qGet.fileContent));
</cfscript>
I wonder how much slower this really is than the file system??
Did anyone ever benchmark any of this?
Taco
-----Original Message-----
From: Taco Fleur
Sent: Wednesday, 16 June 2004 4:21 PM
To: CFAussie Mailing List
Subject: [cfaussie] RE: Display image from db
OK, you had me intriged, I never done this before, simply because I have always been
told not to store images in the db, but what if I run into a db that does!? So I
needed to find out.
<cfsetting enablecfoutputonly="yes" showdebugoutput="no">
<cfsilent>
<cffile action="readbinary" file="C:\Temp\test.gif" variable="thisFile">
<cfquery name="qInsert" datasource="dsnTest_development">
INSERT INTO tblImage
(fileContent)
VALUES (<cfqueryparam value="#thisFile#" cfsqltype="CF_SQL_BLOB">)
</cfquery>
<cfquery name="qGet" datasource="dsnTest_development">
SELECT fileContent
FROM tblImage
</cfquery>
</cfsilent>
<cfcontent type="image/gif; charset=8859_1">
<cfscript>
writeOutput(toString(qGet.fileContent));
</cfscript>
-----Original Message-----
From: Phil Evans [mailto:[EMAIL PROTECTED]
Sent: Wednesday, 16 June 2004 3:55 PM
To: CFAussie Mailing List
Subject: [cfaussie] RE: Display image from db
Thanks for the info.
It's a bit more complex than I had hoped for, so I might try another work
around.
Good to know that it can be done though.
Thanks,
Phil
----- Original Message -----
From: <[EMAIL PROTECTED]>
To: "CFAussie Mailing List" <[EMAIL PROTECTED]>
Sent: Wednesday, June 16, 2004 3:40 PM
Subject: [cfaussie] RE: Display image from db
> Ok I've done this before, and I am sure I got the details from Shaun
> Cornfields Blog's.
>
> Basicaly you need a separate script called from the image tag.
> <img src="getimage.cfm?recordID=#num#">
>
> This script them gets the data from the data base.
>
> <cfquery>
> SQL to get image
> </cfquery>
>
> Then flushes the Output Cache and opens an output stream to the browser
> with the correct headers.
>
> <cfscript>
> context = getPageContext();
> context.setFlushOutput(false);
> response = context.getResponse().getResponse();
> out = response.getOutputStream();
> response.setContentType("image/jpeg");
> response.setContentLength(arrayLen(queryname.filedContent));
> out.write(queryname.filedContent);
> out.flush();
> out.close();
> </cfscript>
>
>
> Try searching for getOutputStream() and Coldfusion.
>
> GC
>
> Original Message:
> -----------------
> From: Phil Evans [EMAIL PROTECTED]
> Date: Wed, 16 Jun 2004 15:31:48 +1000
> To: [EMAIL PROTECTED]
> Subject: [cfaussie] Display image from db
>
>
> Hi All,
>
> I am storing an image in a db - I need to do this so that it can be
accessed
> by crystal reports.
>
> I am trying to figure out how I can retrieve the image from the db, and
> display via cfml.
>
> Any thoughts?
>
> Thanks,
> Phil.
>
>
> ---
> You are currently subscribed to cfaussie as: [EMAIL PROTECTED]
> To unsubscribe send a blank email to
> [EMAIL PROTECTED]
> Aussie Macromedia Developers: http://lists.daemon.com.au/
>
>
> --------------------------------------------------------------------
> mail2web - Check your email from the web at
> http://mail2web.com/ .
>
>
>
> ---
> You are currently subscribed to cfaussie as: [EMAIL PROTECTED]
> To unsubscribe send a blank email to
[EMAIL PROTECTED]
> Aussie Macromedia Developers: http://lists.daemon.com.au/
>
---
You are currently subscribed to cfaussie as: [EMAIL PROTECTED]
To unsubscribe send a blank email to [EMAIL PROTECTED]
Aussie Macromedia Developers: http://lists.daemon.com.au/
Register now for the 3rd National Conference on Tourism Futures, being held in
Townsville, North Queensland 4-7 August - www.tq.com.au/tfconf
---
You are currently subscribed to cfaussie as: [EMAIL PROTECTED]
To unsubscribe send a blank email to [EMAIL PROTECTED]
Aussie Macromedia Developers: http://lists.daemon.com.au/
Register now for the 3rd National Conference on Tourism Futures, being held in
Townsville, North Queensland 4-7 August - www.tq.com.au/tfconf
---
You are currently subscribed to cfaussie as: [EMAIL PROTECTED]
To unsubscribe send a blank email to [EMAIL PROTECTED]
Aussie Macromedia Developers: http://lists.daemon.com.au/