• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 197
  • Last Modified:

How to test for existence of file?

Before outputting a link to a file, I want to make sure that file exists. What's the best way to do that?

Using CFFILE to READ the contents into a variable and then testing for a size gt "" on the variable seems to be too much trouble just to see if it exists.

Thanks.
0
lavachickie
Asked:
lavachickie
2 Solutions
 
CFDevHeadCommented:
FileExists(absolutePath)
0
 
mrichmonCommented:
You can also use EpandPath in conjuction with FileExists

<cfif FileExists(ExpandPath(#variable_with_filename#))>
OUtput link
<cfelse>
don't
</cfif>
0
 
dynabytesCommented:
FileExists(absolutePath)
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now