<cfdirectory action="list" directory="c:\temp" name="dirListing">, will return the contents of the dirctory where you are looking for existance of the file
then you can use this:
<cfloop query="listing">
<cfif name EQ "fileYouLookingFor.csv">
<cfset foundIt = "true">
</cfif>
</cfloop>
<cfif foundIt>
your file exist
</cfif> Sylvano
dsylvano@hotmail.com
"every and each day when I learn something new is a small victory..."
If you only have FTP access to the server, you could do it this way.
Save the code below and put into a file named FtpFileExists.cfm.
[COLOR=666666]<!--- Start FtpFileExists.cfm --->[/color]
[COLOR=666666]<!--- This file returns a boolean value as REQUEST.FtpFileExists --->[/color] <CFPARAM NAME="ATTRIBUTES.port" DEFAULT="21">
<CFIF NOT IsDefined("ATTRIBUTES.username")
OR NOT IsDefined("ATTRIBUTES.password")
OR NOT IsDefined("ATTRIBUTES.server")
OR NOT IsDefined("ATTRIBUTES.folder")
OR NOT IsDefined("ATTRIBUTES.filename")>
You must define the following attributes in this CF_FtpFileExists tag:
[COLOR=000080]<UL>[/color]
[COLOR=000080]<LI>[/color]USERNAME[COLOR=000080]</LI>[/color]
[COLOR=000080]<LI>[/color]PASSWORD[COLOR=000080]</LI>[/color]
[COLOR=000080]<LI>[/color]SERVER[COLOR=000080]</LI>[/color]
[COLOR=000080]<LI>[/color]FILENAME[COLOR=000080]</LI>[/color]
[COLOR=000080]</UL>[/color] <CFABORT> </CFIF>
<CFOUTPUT QUERY="ContentList"> <CFIF NOT IsDirectory
AND ContentList.name IS ATTRIBUTES.filename> <CFSET REQUEST.FtpFileExists = 1> </CFIF> </CFOUTPUT>
<CFFTP ACTION="close" CONNECTION="Request.ConnectionName">
[COLOR=666666]<!--- END FtpFileExists.cfm --->[/color]
Then you'd call it using this method <CF_FtpFileExists
USERNAME="username"
PASSWORD="password"
SERVER="server"
FOLDER="/folder/list/to/file"
FILENAME="filename">
<CFIF REQUEST.FtpFileExists>
The File Exists <CFELSE>
The file doesn't exists </CFIF>
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.