cfdocs

cfcontent

Does either or both of the following:

Syntax

<cfcontent>

Script Syntax ACF11+, Lucee, Railo 4.2+

cfcontent();

Attribute Reference

Name Type Required Default Description
type string No   The MIME content type of the page, optionally followed by
a semicolon and the character encoding. By default,
CFML sends pages as text/html content type in
the UTF-8 character encoding.
deletefile boolean No NO Applies only if you specify a file with the file attribute.

Yes: deletes the file on the server after sending its
contents to the client.
No: leaves the file on the server.
file string No   Name of file whose contents will be the page output. When
using CFML in a distributed configuration, the file
attribute must refer to a path on the system on which the
web server runs. When you use this attribute, any other
output on the current CFML page is ignored; only the
contents of the file is sent to the client.
variable string No   Name of a ColdFusion MX binary variable whose contents can
be displayed by the browser, such as the contents of a chart
generated by the cfchart tag or a PDF or Excel file
retrieved by a cffile action=”readBinary” tag.
When you use this attribute, any other output on the current
CFML page is ignored; only the contents of the file are sent
to the client.
reset boolean No YES The reset and file attributes are mutually exclusive.
If you specify a file, this attribute has no effect.

Yes: discards output that precedes call to cfcontent
No: preserves output that precedes call to cfcontent. In
this case all output is sent with the specified type.

Sending an Excel xls file back to the client

<cfcontent type="application/vnd.ms-excel" file="c:/temp/acmesales03.xls">

Sending an Excel xls file back to the client using cfscript

cfcontent(type="application/vnd.ms-excel", file="c:/temp/acmesales03.xls");