Skip to main content
jbird5k
Inspiring
April 10, 2009
Question

Cfheader /CFcontent producing inconsistent results

  • April 10, 2009
  • 1 reply
  • 1684 views

Hi all

I am using cf header to display a dynically generated report as a word doc. At least this is my goal

i'm using mx7 on appache 2.0 and Firefox 2.0.0.16 [i can not update this] and ie 6 sp 3 for browsers.

no matter how a set this up i don't get the expected results

<cfheader name "content-disposition" value="attachment;filename=#GetInspection.file_number#.doc">

<cfcontent type="application/vnd.msword">

in Firefox the file always downloads as a cfm file. I cant change this.

in ie it down loads as a cfm file but if i elect to save it i can select word.

the other issue with both browsers is that it will not take on the file name assigned it the cf header tag. It just uses the template name.

anyone have a suggestion?

tia

J

    This topic has been closed for replies.

    1 reply

    BKBK
    Community Expert
    Community Expert
    April 12, 2009

    The equality sign is missing for the name attribute. I also think you have to include the file attribute in cfcontent.

    For example, suppose I have stored the file MyFileName.doc in the web root. When the user opens the page I want the file that is displayed to be named SomeOtherFileName.doc instead. Then some possibilities are:

    1) to download and save file

    <cfset

    GetInspection.file_number="SomeOtherFileName">

    <cfheader

    name ="Content-Disposition" value="attachment;filename=#GetInspection.file_number#.doc">

    <cfcontent

    type="application/msword" file="C:\ColdFusionCentaur\wwwroot\MyFileName.doc">

    2) to open and view file in the browser

    <cfset

    GetInspection.file_number="SomeOtherFileName">

    <cfheader

    name ="Content-Disposition" value="inline;filename=#GetInspection.file_number#.doc">

    <cfcontent

    type="application/msword" file="C:\ColdFusionCentaur\wwwroot\MyFileName.doc">

    jbird5k
    jbird5kAuthor
    Inspiring
    April 14, 2009

    Thank you for your reply.

    The template is report_draft.cfm, and is used for mulitple inspection reports, so the name of the report when downloaded has to be inspection file number.doc.

    I have tried your suggestions and i am still having the same issues.  So,the report_draft.cfm template is made up of 20 + includes, one for each section of the report.  Should this have an impact on how the CFheader/CFcontent performs?

    thanks

    J

    ilssac
    Inspiring
    April 14, 2009

    you may also want to add a reset="true" to your <cfcontent...> tag so that all that white space generated by all that CFML in all those includes does not throw the browser off.

    <cfcontent reset="true" type="application/msword"...>