Skip to main content
Known Participant
August 20, 2008
Question

showing the images

  • August 20, 2008
  • 2 replies
  • 324 views
Hi.I need to show the images wich are in folder images & display "No Image" for those we have not the image in the folder.
I wrote this code:

<cfset PhotoLocation =
"e:\www\NeedBattery\images\manufacturer\<cfoutput>#getBrands.cat_level2_image#</cfoutput>">
<cfif not FileExists(PhotoLocation)>
<cfoutput>no image</cfoutput>
<cfelse>
<a><img src="#imagePath#images/manufacturer/#getBrands.cat_level2_image#" width="60" height="40" /></a>
</cfif>

but the result is incorrect & typed "NO Image" for all the images.
would u plz help me what is wrong with my code?
thanks
    This topic has been closed for replies.

    2 replies

    Inspiring
    August 20, 2008
    Try
    <cfif FileExists(ExpandPath("\NeedBattery\images\manufacturer\<cfoutput>#getBrands.cat_level2_image#</cfoutput>"))>

    If you still want to use the PhotoLocation you need to amend thus:
    <cfset PhotoLocation =
    "\NeedBattery\images\manufacturer\<cfoutput>#getBrands.cat_level2_image#</cfoutput>">
    <cfif FileExists(ExpandPath(PhotoLocation))>
    Known Participant
    August 20, 2008
    thanks for reply,but still I get the same result.No Image for all images.
    Inspiring
    August 20, 2008
    I generally troubleshoot my if/else problems like this.

    <cfif the variable is what I expect it to be>
    true
    <cfelse>
    output or dump the variable.