Skip to main content
Participant
January 18, 2011
Question

Problem with downloading 2007 formats

  • January 18, 2011
  • 2 replies
  • 272 views

I have a problem with downloading 2007 format files in my application. We can upload the 2007 formats without any problem. But, When we try to download them, we are receiving a 'Page cannot be displayed' error.

When we add the corresponding MIME-TYPES into IIS(Version 6.0) of the system(Test Environment), the problem got resolved. But there was a constraint to add the MIME-TYPES in the Production Box.

Can you please provide any alternate solution using CF code. I am pasting my sample code that my system is using for this.

    This topic has been closed for replies.

    2 replies

    Community Expert
    January 18, 2011

    For CF to set the MIME type for those files, it would have to be configured as a handler for those file extensions. By default, CF doesn't process requests for files other than .cfm, .cfc, etc.

    You could write a download application that uses CFCONTENT to push files to the client, but the user would have to request your CF page, which might have a URL like this:

    http://yourserver/download.cfm?file=myfile.docx

    Or, you could map those file extensions to CF, but that would be a bad idea for several reasons. Even if it wasn't a bad idea, it would be harder to change on the server than the MIME types in IIS.

    Frankly, you should fix this the right way - by having the server administrator add the correct MIME types.

    Dave Watts, CTO, Fig Leaf Software

    http://www.figleaf.com/

    http://training.figleaf.com/

    Dave Watts, Eidolon LLC
    Participant
    January 18, 2011

    <cfswitch expression="#fileext#">

    <cfcase value="gif"> <cfset fileMimeType = "image/gif"> </cfcase>

    <cfcase value="jpeg"> <cfset fileMimeType = "image/jpeg"> </cfcase>

    <cfcase value="pdf"> <cfset fileMimeType = "application/pdf"> </cfcase>

    <cfdefaultcase>

    <cfset fileMimeType = "application/octet-stream">

    </cfdefaultcase>

    </cfswitch>