328
Chapter 17 Managing Files on the Server
Writing a text file
You can use
cffile
to write a text file based on dynamic content. For example, you
could create static HTML files or log actions in a text file.
To create a form in which to enter data for a text file:
1
Open a new file in ColdFusion Studio.
2
Modify the file so that it appears as 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 your name: <input type="text" name="Name" size="25">
<p>Enter the name of the file: <input type="text" name="FileName"
size="25">
<p>Enter your message:</p>
<textarea name="message"cols=45 rows=6></textarea>
</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 ColdFusion 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.
Summary of Contents for COLDFUSION 5-DEVELOPING
Page 1: ...Macromedia Incorporated Developing ColdFusion Applications MacroMedia ColdFusion 5 ...
Page 58: ...38 Chapter 3 Querying a Database ...
Page 134: ...114 Chapter 7 Updating Your Database ...
Page 210: ...190 Chapter 10 Reusing Code ...
Page 232: ...212 Chapter 11 Preventing and Handling Errors ...
Page 238: ...218 Chapter 12 Using the Application Framework ...
Page 262: ...242 Chapter 12 Using the Application Framework ...
Page 278: ...258 Chapter 13 Extending ColdFusion Pages with CFML Scripting ...
Page 320: ...300 Chapter 15 Indexing and Searching Data ...
Page 336: ...316 Chapter 16 Sending and Receiving E mail ...
Page 374: ...354 Chapter 18 Interacting with Remote Servers ...