• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

CF 10 cfcontent application/msword displays HTML code instead of document?

New Here ,
May 19, 2014 May 19, 2014

Copy link to clipboard

Copied

I have this code for a generic template:

   <cfset fileName="c:\temp\wordTmpDoc"&randRange(1,100000)&".htm">

    <cfif fileExists(fileName)><cffile action="delete" file="#fileName#"></cfif>

    <cfsavecontent variable="htm"><CFINCLUDE template="#incl#.cfm"></cfsavecontent>

    <cffile action="write" file="#fileName#" output="#htm#">

    <cfcontent file="#fileName#" deletefile="no" type="application/msword">

Note the CFINCLUDE. I also have another template that goes through generating the html in a cfsavecontent and at the bottom it has essentially the same code but uses the HTML generated on the page as the content for the document. The above generic version brings up MS Word but the content is the HTML code, while the page that has local cfsavecontent wrapping the HTML, the document displays properly.

Views

235

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
May 23, 2014 May 23, 2014

Copy link to clipboard

Copied

LATEST

OK, now I'm really confused. I put a cfdump on the generic template, removed it, and moved a closing </div> to the next line on the cfinclude file and now....... it produces a proper Word doc instead of HTML! Ghost in the machine. I did not change anything important one either file, and I lost a LOT of time trying to debug the issue. If anyone else encounters this problem and can explain the cause and the solution, please feel free to contribute.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation