I'd also recommend storing the file extension in the products table in your
db, however, if you need to get it from file system, the simplest way is
probably this:

<cfdirectory action="list" name="rsprodimg" filter="#sku#.*"
directory="#ExpandPath('images')#">
<cfif len(rsprodimg.name[1])><img src="images/#rsprodimg.name[1]#"><cfelse>
<img src="images/notavailable.gif"></cfif>

> FileExists():

> <cfif FileExists("images/#sku#.gif")>
>     <img src="images/#sku#.gif">
> <cfelseif FileExists("images/#sku#.jpg")>
>     <img src="images/#sku#.gif">
> </cfif>

> Though I'd prefer Tonys method, so you don't have to do a
> lot of file checking.  We use it a lot on a app here and
> haven't run into any performance problems, but a database
> solution would or course, be better.

> Tim P.

> ----- Original Message -----
> From: "Larry Juncker" <[EMAIL PROTECTED]>
> To: "CF-Talk" <[EMAIL PROTECTED]>
> Sent: Monday, September 09, 2002 9:10 AM
> Subject: CFDirectory Question


>> I have a shopping cart that I have created and the images
>> can be either gif
>> or jpg.
>>
>> Since I am dynamically pulling from the images folder,
>> how can I check to
>> see which image exists for a particular item.
>>
>> I am currently doing this:
>>
>> <img src="images/#sku#.gif">
>>
>> I need to be able to see if #sku#.gif exists or #sku#.jpg
>> and then display
>> the proper image.
>>
>> Any help would be greatly appreciated.
>>
>>
> __________________________________________________________
> ____________
> Structure your ColdFusion code with Fusebox. Get the
> official book at http://www.fusionauthority.com/bkinfo.cfm
> 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


Isaac
Certified Advanced ColdFusion 5 Developer

www.turnkey.to
954-776-0046

______________________________________________________________________
Structure your ColdFusion code with Fusebox. Get the official book at 
http://www.fusionauthority.com/bkinfo.cfm
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