Reading, Writing, And Appending To A Text File; Reading A Text File; Writing A Text File - MACROMEDIA COLDFUSION 4.5-DEVELOPING WEB Develop Manual

Developing web applications with coldfusion
Table of Contents

Advertisement

Chapter 14: Managing Files on the Server

Reading, Writing, and Appending to a Text File

In addition to managing files on the server, you can use CFFILE to read, create, and
modify text files.
This gives you the ability to
Create log files.
Generate static HTML documents.
Use text files to store information that can be brought into Web pages.

Reading a text file

You can use CFFILE to read an existing text file. The file is read into a dynamic
parameter which you can use anywhere in the application page. For example, you
could read a text file and then insert its contents into a database. Or you could read a
text file and then use one of the find and replace functions to modify the contents.
To read a text file:
1.
Create a new file in Studio.
2.
Modify the file so that it appears as follows:
<HTML>
<HEAD>
</HEAD>
<BODY>
Ready to read the file:<BR>
4
<CFFILE ACTION="Read"
4
FILE="C:\inetpub\wwwroot\mine\message.txt"
4
VARIABLE="Message">
<CFOUTPUT>
</CFOUTPUT>
</BODY>
</HTML>
3.
Replace
text file on your server.
4.
Save the file as

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.
<TITLE>Read a Text File</TITLE>
#Message#
c:\inetpub\wwwroot\mine\message.txt
readtext.cfm
with the location and name of a
and view it in your browser.
227

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the COLDFUSION 4.5-DEVELOPING WEB and is the answer not in the manual?

This manual is also suitable for:

Coldfusion 4.5

Table of Contents