Writing A Text File - MACROMEDIA COLDFUSION 5-DEVELOPING Develop Manual

Table of Contents

Advertisement

328

Writing a text file

You can use
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
2
3
To write a text file:
1
2
3
4
5
to write a text file based on dynamic content. For example, you
cffile
Open a new file in ColdFusion Studio.
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>
Save the file as
writetextfileform.cfm
Open a new file in ColdFusion Studio.
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>
Modify the path C:\inetpub\wwwroot\mine\ to point to a path on your server.
Save the file as
writetextfileaction.cfm
View the file
writetextfileform.cfm
the form.
Chapter 17 Managing Files on the Server
in
under the Web root directory
myapps
.
in your browser, enter values, and submit
.

Advertisement

Table of Contents
loading

This manual is also suitable for:

Coldfusion 5

Table of Contents