User Guide

Chapter 1: ColdFusion Tags 57
Example The following example creates a file with the information a user entered into an HTML
insert form:
<CFFILE ACTION="Write"
FILE="c:\files\updates\#Form.UpdateTitle#.txt"
OUTPUT="Created By: #Form.FullName#
Date: #Form.Date#
#Form.Content#">
If the user submitted a form where:
UpdateTitle="FieldWork"
FullName="World B. Frueh"
Date="10/30/98"
Content="We had a wonderful time in Cambridgeport."
ColdFusion would create a file named FieldWork.txt in the c:\files\updates\
directory and the file would contain the text:
Created By: World B. Frueh
Date: 10/30/98
We had a wonderful time in Cambridgeport.
This following examples show the use of the MODE attribute for UNIX. The first,
creates the file
/tmp/foo with permissions defined as rw-r—r-- (owner=read/write,
group/other=read).
<CFFILE ACTION="Write"
FILE="/tmp/foo"
MODE=644>
This example appends to the specified file and makes permissions read/write (rw) for
all.
<CFFILE ACTION="Append"
DESTINATION="/home/tomj/testing.txt"
MODE=666
OUTPUT="Is this a test?">
The next example uploads a file and gives it rwx-rw-rw permissions (owner/group/
other=read/write).
CFFILE ACTION="Upload"
FILEFIELD="fieldname"
DESTINATION="/tmp/program.exe"
MODE=755>