Saving content to a .DOC file using ColdFusion

I have no problem writing content to a .doc file. The problem I'm running into is to download the file automatically after downloading. I just want the .doc file to be generated in the background, then the user can download the file from the webpage at any time. Here's the code I'm working with:

<cfheader name="Content-disposition" value="filename=Quote_#arguments.QuoteNumber#_#arguments.Revision#.doc">
<cfcontent type="application/msword">

<cfoutput>#WordDoc#</cfoutput>

<cffile action="copy" source="#application.AbsPath#\media\quotes\BlankQuote.doc" destination="#application.AbsPath#\media\quotes\Quote_#arguments.QuoteNumber#_#arguments.Revision#.doc" />

<cffile action="write" file="#application.AbsPath#\media\quotes\Quote_#arguments.QuoteNumber#_#arguments.Revision#.doc" output="#WordDoc#" />

      

+3


source to share


1 answer


You problem is the tag <cfheader>

... what triggers the document to open.

I'll do something like this instead.

<cfsavecontent variable="whatever">
<cfoutput>#WordDoc#</cfoutput>
</cfsavecontent>
<cffile action="write" file="#application.AbsPath#\media\quotes\Quote_#arguments.QuoteNumber#_#arguments.Revision#.doc" output="#whatever#" />





+7


source







All Articles