December 17th, 2003, 07:52 AM
How do I know if a file is there?
I am trying to check to see if a specific file in a directory is there before I allow the user to move on.
I'm looking for a way to basically say,
<cfif #file# exists>
You need to upload the file.
I looked at the CFFILE and CFDIRECTORY tags, and they don't seem to have a way to check like this.
I looked into the list feature of CFDirectory, but I thought there must be a better way than to retrieve the list of files, then look through the list to see if the file name is there.
Thanks for the help.
December 17th, 2003, 09:48 AM
hopefully the following snippet helps you out:
<!--- Absolute path + filname to the expected file --->
<cfset myFile = "C:\bogus.txt">
<cfoutput>#myFile#</cfoutput> DOES NOT EXIST!!!
Last edited by DeepDown; December 17th, 2003 at 09:53 AM.
** Don't expect me to code your needs, but if I am able to help, I'm willing. Shout, grab and use the hand!
** Man can no more own the land we walk upon, as they can lay claim on the air that we breath
** DeepDown I'm addicted to structures.... ohw and music
** Almost forgot I had an account here [*o*]
December 17th, 2003, 11:07 AM
Look at that! the FileExists function is right there on Page 206 of the Cold Fusion5 Language Refrence! How did I miss that!?!?
Thanks! I feel pretty stupid now. I use that book almost every day, and don't remember ever seeing that function.