Adobe COLDFUSION 9 Manual page 1255

Developing applications
Hide thumbs Also See for COLDFUSION 9:
Table of Contents

Advertisement

DEVELOPING COLDFUSION 9 APPLICATIONS
Using External Resources
3
Save the file as readtext.cfm in the myapps directory under your web_root and view it in the browser.
Writing a text file on the server
You can use the
tag to write a text file based on dynamic content. For example, you could create static HTML
cffile
files or log actions in a text file.
Create a form in to capture data for a text file
Create a ColdFusion page with the following content:
1
<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>
<p>Enter the name of the file: <input type="text" name="FileName" size="25">.txt</p>
<p>Enter your message:
<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 in the myapps directory under your web_root
2
Note: The form does not work until you write an action page for it (see the next procedure).
Write a text file
Create a ColdFusion page with the following content:
1
<html>
<head>
<title>Write a Text File</title>
</head>
<body>
<cffile action="write"
file="C:\inetpub\wwwroot\mine\#Form.FileName#.txt"
output="Created By: #Form.Name#
#Form.Message# ">
</body>
</html>
Modify the path C:\inetpub\wwwroot\mine\ to point to a path on your server.
2
Save the file as writetextfileaction.cfm in the myapps directory under your web_root.
3
4
View the file writetextfileform.cfm in the browser, enter values, and submit the form.
The text file is written to the location you specified. If the file exists, it is replaced.
Last updated 8/5/2010
.
1250

Advertisement

Table of Contents
loading

Table of Contents