User Guide

cffile 129
ColdFusion MX:
Changed use of slashes in paths: you can use forward (/) or backward (\) slashes in paths on
both UNIX and Windows systems.
Changed file hierarchy requirements: ColdFusion does not require that you put files and
directories that you manipulate with this tag below the root of the web server document
directory.
Changed directory path requirements for the destination attribute: a directory path that you
specify in the
destination attribute does not require a trailing slash.
Deprecated the system value of the attributes attribute.
Deprecated the temporary value of the attributes attribute. In ColdFusion MX, it is a
synonym for
normal. It might not work in later releases.
Changed the action attribute options read, write, append and move: they support a new
attribute,
charset.
The archive value of the attributes attribute is obsolete and has no effect.
Example
<!--- This shows how to write, read, update, and delete a file using CFFILE.
This is a view-only example. --->
<!---
<cfif IsDefined("form.formsubmit") is "Yes">
<!--- The form has been submitted, now do the action. --->
<cfif form.action is "new">
<!--- make a new file --->
<cffile action="Write"
file="#GetTempDirectory()#foobar.txt"
output="#form.the_text#">
</cfif>
<cfif form.action is "read">
<!--- read existing file --->
<cffile action="Read"
file="#GetTempDirectory()#foobar.txt"
variable="readText">
</cfif>
<cfif form.action is "add">
<!--- update existing file --->
<cffile action="Append"
file="#GetTempDirectory()#foobar.txt"
output="#form.the_text#">
</cfif>
<cfif form.action is "delete">
<!--- delete existing file --->
<cffile action="Delete"
file="#GetTempDirectory()#foobar.txt">
</cfif>
</cfif>
<!--- Set some variables. --->
<cfparam name="fileExists" default="no">
<cfparam name="readText" default="">