What are fileexists?

FileExists

Description

Determines whether a file exists.

Returns

Yes, if the file specified in the parameter exists; No, otherwise.

Category

System functionsDecision functions

Function syntax

FileExists(absolute_path)

See also

DirectoryExistsExpandPathGetTemplatePath

Parameters

ParameterDescription

absolute_path

An absolute path

Usage

To access a file on a remote system, the account (for Windows) or user (for UNIX and Linux) that is running ColdFusion must have permission to access the file, directory, and remote system. For example, if you run ColdFusion MX in the Server Configuration as a Windows service, by default it runs under the local system account, which does not have sufficient privileges to access remote systems. You can change this, however, on the Log On page of the Services Properties dialog box.

Example

<h3>FileExists Example</h3>

<cfset thisPath = ExpandPath("*.*")>
<cfset thisDirectory = GetDirectoryFromPath(thisPath)>
<cfoutput>
The current directory is: #GetDirectoryFromPath(thisPath)#
<cfif IsDefined("FORM.yourFile")>
<cfif FORM.yourFile is not "">
<cfset yourFile = FORM.yourFile>
   <cfif FileExists(ExpandPath(yourfile))>
   <p>Your file exists in this directory. You entered
   the correct file name, #GetFileFromPath("#thisPath#/#yourfile#")#
   <cfelse>


http://www.adobe.com/livedocs/coldfusion/7/htmldocs/wwhelp/wwhimpl/common/html/wwhelp.htm?context=ColdFusion_Documentat


Was this article helpful?

mood_bad Dislike 0
mood Like 0
visibility Views: 2616