Hi,

I need to check for the existence of an image file and either display
the file, if it exists, or display a default file.

I have worked up the following code, which produces no errors, but it
will not display the default file when the file I'm checking for doesn't
exist. Can anyone see the error?

<CFOUTPUT QUERY="EmpName">
<CFSET thisPath= ExpandPath("*.*")>
<CFSET thisDirectory= GetDirectoryFromPath(thisPath)>
<cfif FileExists("#thisPath#/#thisDirectory#/pics/#FILENAME#.jpg")>
<IMG SRC="pics/no_pic.jpg" 
height=155 width=128 alt="#FN# #MN# #LN#">
<cfelse><IMG SRC="pics/#FILENAME#.jpg" 
height=155 width=128 alt="#FN# #MN# #LN#"></cfif>
</CFOUTPUT>

In either case, the code, "pics/#FILENAME#.jpg," gets executed. If I
swap the two parts of the CFIF, then "pics/no_pic.jpg" gets executed in
either case. So I know my test always evaluates to false. I tried
changing the fileExists parameter to "pics/#FILENAME#.jpg", but I get
the same result.

This template is in the root, and the picture files are in [root]/pics/

Thanks,
--John
------------------------------------------------------------------------------
Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
To Unsubscribe visit 
http://www.houseoffusion.com/index.cfm?sidebar=lists&body=lists/cf_talk or send a 
message to [EMAIL PROTECTED] with 'unsubscribe' in the body.

Reply via email to