I need to check if a file exists on the server and if so, run some code.

Whats the best way to check if the file "test.txt" exists in a directory

The below doesn't seem to work. Note that the filename can change but the 
file extension (.txt) will stat the same.

<cfset FileName = ListLast(url.filename, "\")>
<cfset DirPath = Left(url.filename, Evaluate(Len(url.filename) - 
len(FileName) - 1))>
<cfset TheFile = ListLast(url.filename)>
<cfset TheFolder = DirPath>

<cfparam name="dir" default="#TheFolder#">
<cfdirectory action="LIST" directory="#dir#" name="FileCheck">
<cfoutput query="FileCheck">
<cfif FileCheck.name IS "test.txt">
   <h3>Found Match</h3>
<cfelse>
   <h3>No Match</h3>
</cfif>
</cfoutput>



+-----------------------------------------------------------------------------------+ 

Philip Humeniuk
[EMAIL PROTECTED]
[EMAIL PROTECTED]
+------------------------------------------------------------------------------------+



-------------------------------------------------------------------------
This email server is running an evaluation copy of the MailShield anti-
spam software. Please contact your email administrator if you have any
questions about this message. MailShield product info: www.mailshield.com

-----------------------------------------------
To post, send email to [EMAIL PROTECTED]
To subscribe / unsubscribe: http://www.dfwcfug.org

Reply via email to