Skip to main content
Known Participant
March 5, 2010
Question

Coldfusion Doc Download from Word Hyperlink

  • March 5, 2010
  • 1 reply
  • 977 views

I am using cfheader/cfcontent to deliever documents from my server... this works great except when someone links to a doc file from Outlook or Word then it gives "cannot open specified file."  If i take the link from Word or Outlook and paste it into a browser it works fine.

Thanks for any help

    This topic has been closed for replies.

    1 reply

    Inspiring
    March 5, 2010

    It would be helpful to see your source code.

    whoisit28Author
    Known Participant
    March 5, 2010

    <cfif isDefined("url.sales") and isnumeric(url.sales)>
        <cfset dObj = createObject("component","UDF.downloads")>
        <cfset FileName = dObj.salesDownloadRecord(url.sales)>
        <cfif FileName neq 0>
            <cfif FileName contains "/">
                <cflocation addtoken="no" url="#FileName#">   
            <cfelse>
                <cfheader
                    name="content-disposition"
                    value="attachment; filename=#FileName#">
                <cfcontent
                    type="application/pdf"
                    file="C:\www\shared_library\#FileName#">
            </cfif>
           </cfif>
    </cfif>

    it is weird that it works all the time except when you link it from Word

    Inspiring
    March 5, 2010

    I suspect that you need to change the value for the type attribute of CFCONTENT to match the MIME type for file format you are downloading.

    You might try using the getMimeType from cflib.org to determine the MIME type to use.

    http://www.cflib.org/udf/getMimeType

    Note that I assume the problem is occuring when the block within CFELSE in your code is run.