Today, I'm very clear to know how to use FileExists and IsImage in coldfusion. Before time, I though these two tags working in the same boat but once I used these two, both are very different but slightly same.

What's the slightly same? It's very simple that we're not using the full path of file like that.

view plain print about
1<!--- Checking image --->
2<cfif FileExists("image.jpg")>
3    Image exists.
4<cfelse>
5    Image doesn't exist.
6</cfif>
7
8<!--- Checking file --->
9<cfif FileExists("myfile.txt")>
10    File exists.
11<cfelse>
12    File doesn't exist.
13</cfif>

If we're using the full path of image/file, FileExists doesn't work at all. At that time, we need to use IsImage for checking image exist or not.

view plain print about
1<!--- Checking Image with full path --->
2<cfif IsImage("http://www.ppshein.net/images/ppshein_banner.jpg")>
3    Image exists.
4<cfelse>
5    Image doesn't exist.
6</cfif>

Because, FileExists can check the directory of image/file and cannot check the full path URL of image/file. In this case, we need to use IsImage for checking image exists or valid type of image.

Sorry, I really missed out IsImageFile function of coldfusion which can support to check whether an image file is valid. Thanks, Ray for commenting about that.