Using cfcontent
The
cfcontent
MIME type of the content returned by a ColdFusion page and, optionally, define the filename of
a file to be downloaded by the current page. By default, ColdFusion returns a MIME content
type of text/html so that a web browser renders your template text as a web page.
As with
cffile
MX Administrator.
About MIME types
A MIME type is a label that identifies the contents of a file. the browser uses the MIME type
specification to determine how to interact with the file. For example, the browser could open a
spreadsheet program when it encounters a file identified by its MIME content type as a
spreadsheet file.
A MIME content type consists of
content types:
•
text/html
•
image/gif
•
application/pdf
Changing the MIME content type with cfcontent
You use the
cfcontent
with the content generated from your ColdFusion page.
The
cfcontent
returned by the current page.
To change the MIME content type with cfcontent:
Create an HTML page with the following content:
1
<h1>cfcontent_message.htm</h1>
<p>This is a <em>test message</em> written in HTML.</p>
<p>This is the <em>second paragraph</em> of the test message.
As you might expect, it is also written in HTML.</p>
Save the file as cfcontent_message.htm in the myapps directory under your web_root.
2
This HTML file will be called by the ColdFusion file that you write in steps 3 through 7.
Create a ColdFusion page with the following content:
3
<html>
<head>
<title>cfcontent Example</title>
</head>
<body>
<h3>cfcontent Example</h3>
830
Chapter 37: Managing Files on the Server
tag downloads files from the server to the client. You can use this tag to set the
and
you can disable
cfdirectory,
"type/subtype"
tag to change the MIME content type that returns to the browser along
tag has one required attribute,
processing in the ColdFusion
cfcontent
format. The following are common MIME
, which defines the MIME content type
type