Created before 2005, updated 2016
ColdFusion: Force Download of File
I've used this in the past. It's dependent on the file actually existing on the filesystem in the <path-to-file> directory.
<cfset yourFileName="whatever.csv"> <cfcontent type="application/x-unknown"> <cfheader name="Content-Disposition" value="attachment;filename=#yourFileName#"> <cfheader name="Content-Description" value="This is a tab-delimited file."> <cflocation url="<path-to-file>/#yourFileName#">
From a reader named Joe Velez, in 2005 an improvement:
<cfset yourFileName="download.txt"> <cfcontent type="application/x-unknown"> <cfheader name="Content-Disposition" value="attachment;filename=#yourFileName#"> <cfheader name="Content-Description" value="This is a tab- delimited file."> <cfinclude template='#yourfilename#'>