228
Developing Web Applications with ColdFusion
To create a form in which to enter data for a text file:
1.
Open a new file in Studio.
2.
Modify the file so that it appears a follows:
<HTML>
<HEAD>
<TITLE>Put Information into a Text File</TITLE>
</HEAD>
<BODY>
<H2>Put Information into a Text File</H2>
<FORM ACTION="writetextfileaction.cfm" METHOD="POST">
<p>Enter you name: <INPUT TYPE="text" NAME="Name" SIZE="25">
<p>Enter you the name of the file: <INPUT TYPE="text"
NAME="FileName" SIZE="25">
<p>Enter your message:</p>
<INPUT TYPE="textarea" NAME="message"cols=45 rows=6>
</p>
<INPUT TYPE="submit" NAME="submit" VALUE="Submit">
</FORM>
</BODY>
</HTML>
3.
Save the file as
writetextfileform.cfm
in
myapps
under the Web root directory
.
To write a text file:
1.
Open a new file in Studio.
2.
Modify the file so that it appears as follows:
<HTML>
<HEAD>
<TITLE>Untitled</TITLE>
</HEAD>
<BODY>
<CFFILE ACTION="Write"
FILE="C:\inetpub\wwwroot\mine\#form.filename#"
OUTPUT="Created By: #Form.Name#
#Form.Message# ">
</BODY>
</HTML>
3.
Modify the path
C:\inetpub\wwwroot\mine\
to point to a path on your server.
4.
Save the file as
writetextfileaction.cfm
.
5.
View the file
writetextfileform.cfm
in your browser, enter values, and submit
the form.
The text file is written to the location you specified.
You can use
CFFILE ACTION="Append"
to append additional text to the end of an
existing text file, for example, when creating log files.
Summary of Contents for COLDFUSION 4.5-DEVELOPING WEB
Page 1: ...Allaire Corporation Developing Web Applications with ColdFusion ColdFusion 4 5...
Page 14: ...xiv Developing Web Applications with ColdFusion...
Page 26: ...xxvi Developing Web Applications with ColdFusion...
Page 34: ...8 Developing Web Applications with ColdFusion...
Page 70: ...44 Developing Web Applications with ColdFusion...
Page 84: ...58 Developing Web Applications with ColdFusion...
Page 114: ...88 Developing Web Applications with ColdFusion...
Page 148: ...122 Developing Web Applications with ColdFusion...
Page 174: ...148 Developing Web Applications with ColdFusion...
Page 208: ...182 Developing Web Applications with ColdFusion...
Page 244: ...218 Developing Web Applications with ColdFusion...
Page 274: ...248 Developing Web Applications with ColdFusion...
Page 288: ...262 Developing Web Applications with ColdFusion...
Page 300: ...274 Developing Web Applications with ColdFusion...
Page 350: ...324 Developing Web Applications with ColdFusion...
Page 362: ...336 Developing Web Applications with ColdFusion...