Rick,

Here's what I do. 

First, I'm assuming here that the directory for your images is a
subdirectory of the current template directory. Given that I typically
set up a ColdFusion variable for the image directory as:

<CFSET ImageDir= GetDirectoryFromPath(ExpandPath("*.*")) & "images\">

This allows me just to have the name of the image file in the database
without path information, as that may change at any point.

Then I run a query to get the image stuff:

<CFQUERY NAME="ImageDB" DATASOURCE="#DSN#" DBTYPE="ODBC"
BLOCKFACTOR="100" CACHEDWITHIN="#CreateTimeSpan(0,0,30,0)#">
      SELECT     ImageName,Caption,image_ID,Short_Desc
      FROM       Images
      ORDER BY   image_ID
</CFQUERY>

Then I make sure that the image really exists in the specified
directory, and if it does, display the image, otherwise display a
default image:

<cfset Image_Name = ImageDir & ImageDB.ImageName>

<CFIF FileExists(Image_Name)>
     <cfoutput><img src="#Image_Name#"></cfoutput>
<CFELSE>
     <img src="images/default.gif">
</CFELSE>

hth,

larry

-- 
Larry C. Lyons
ColdFusion/Web Developer
EBStor.com
8870 Rixlew Lane, Suite 201
Manassas, Virginia 20109-3795
tel: (703) 393-7930 x253
fax: (703) 393-2659
http://www.ebstor.com
http://www.pacel.com
email: [EMAIL PROTECTED]

Chaos, panic, and disorder - my work here is done.
--

Richard L Smith wrote:
> 
> Hello:
> 
> I am using CF4.0 with an Access 97 db to display an image the field containd
> the path to the image it's
> images/a100101.gif  this is then passed to an <img src="#images#"> tag when
> I run it, all I get is an
> empty image container but know error messages.
> 
> Any ideas
> 
> Thanks
> 
> Rick
------------------------------------------------------------------------------------------------
Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists or send a message 
with 'unsubscribe' in the body to [EMAIL PROTECTED]

Reply via email to