27 November 2008

Downloading files from the database with CF

If you use your database as a file store and coldfusion as your webserver, you'll doubtless one day want to download those files from a cfm page.

here are two useful snippets that had me stuck for a while:

To download the image:

< cfheader name="Content-Disposition" value="attachment; filename=" >
< cfcontent type="#fileType#/#fileSubtype#" variable="#fileData#" >


ALWAYS CHECK:
this is important, you need to enable blob downloads in cfadmin.

  1. Open up your datasource in cfadmin,

  2. click advanced,

  3. check the checkbox marked: "Enable binary large object retrieval (BLOB)."

1 comment:

Saiful Alam said...
This comment has been removed by a blog administrator.