Link to home
Start Free TrialLog in
Avatar of jameskane
jameskane

asked on

COLDFUSION - testing to see if file exists

I have a directory of images which also contains the cfml page that utilizes those images to populate a vertical scroller. Images and cfml are at the same level in the directory.

The scroller is implemented within the cfml page as follows (extract of code):

<div class="liknoscroller_item" style="display: none;"><img src="image6.jpg" />
<!-- See the "Item Info" tab for the displayed text "caption"  -->
</div>
<div class="liknoscroller_item" style="display: none;"><img src="image7.jpg" />
<!-- See the "Item Info" tab for the displayed text "caption"  -->
</div>
<div class="liknoscroller_item" style="display: none;"><img src="image8.jpg" />
<!-- See the "Item Info" tab for the displayed text "caption"  -->
</div>

 
(above is an 3 line extract of the code supporting the 10 images - image1.jpg..... image10.jpg)




Everything works correctly - provided the user has uploaded all 10 images.

However, if he has only uploaded 9 of the 10 images then the image scroller shows the broken image symbol for that image.

I need a test to determine if an image is missing and then a related action using <cfif > so that the line with the missing image is skipped and is ignored by the scroller.

I have tried the following approach utilizing fileexists, but it does not work. In the example below, the line gets ignored - regardless whether the image3.jpg exists or not.

<cfif FileExists("image3.jpg")>
<div class="liknoscroller_item" style="display: none;"><img src="image3.jpg" />
<!-- See the "Item Info" tab for the displayed text "caption"  -->
       </div></cfif>

Appreciate if someone can take a look and let me know my stupid mistake or recommend an alternative approach
ASKER CERTIFIED SOLUTION
Avatar of _agx_
_agx_
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of jameskane
jameskane

ASKER

Perfect. The ExpandPath was the answer.

Thanks again

Jim