cfcontent

Does either or both of the following:
* Sets the MIME content encoding header for the current page
* Sends the contents of a file from the server as the page
output

 <cfcontent>

 cfcontent();

Attribute Reference for the cfcontent tag

type

Required: 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. Values:
  • text/html
  • text/plain
  • application/msword
  • application/msexcel
  • application/poscript
  • application/x-zip-compressed
  • application/pdf
  • application/rtf
  • video/x-msvideo
  • video/quicktime
  • video/x-mpeg2
  • audio/x-pn/realaudio
  • audio/x-mpeg
  • audio/x-waw
  • audio/x-aiff
  • audio/basic
  • image/tiff
  • image/jpeg
  • image/gif
  • image/x-png
  • image/x-photo-cd
  • image/x-MS-bmp
  • image/x-rgb
  • image/x-portable-pixmap
  • image/x-portable-greymap
  • image/x-portablebitmap

deletefile

Required: No
Default: 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

Required: 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

Required: 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

Required: No
Default: 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.

Examples sample code using the cfcontent tag


Sending an Excel xls file back to the client

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

Fork me on GitHub