7 Replies Latest reply on Nov 24, 2006 7:59 AM by sean69

    Force Download

    Level 7
      Why won't this work? Its from the Live Docs but using a MP3 instead of using
      an Excel spreadsheet from the example.

      <cfheader name="Content-Disposition" value="inline;
      <cfcontent type="audio/mpeg" file="c:\temp\advocate-show3-48kbit.mp3">

      I want to force a download of the MP3. Any better / working examples of

        • 1. Re: Force Download
          Level 7
          Ok, now I found this:

          <cfheader name="Content-disposition"
          <cfcontent type="audio/mpg"

          Still doesnt work... hmmm.. What am I missing here?

          • 2. Re: Force Download
            Level 7
            > doesnt work

            Can you elaborate on that? Obviously it doesn't force the D/L, but what
            DOES it do, instead?

            • 3. Re: Force Download
              Level 7
              It shows a watermark of Quicktime in the background with a question mark.

              "Adam Cameron" <adam_junk@hotmail.com> wrote in message
              >> doesnt work
              > Can you elaborate on that? Obviously it doesn't force the D/L, but what
              > DOES it do, instead?
              > --
              > Adam

              • 4. Re: Force Download
                Kronin555 Level 1
                If you change the content type to "unknown", it will force the browser to open a save dialog rather than attempting to deal with it based on its advertised content type.
                • 5. Re: Force Download
                  Level 7
                  Tried that and got the same result.

                  • 6. Re: Force Download
                    Kronin555 Level 1
                    Is this in IE? What does it do in other browsers? What do the actual response headers look like?
                    • 7. Re: Force Download
                      sean69 Level 1
                      I just went trough something similar,.. I found IE and mozilla behaved differently depending on ~where~ the header and content tags were placed on the page..

                      maybe try:
                      - place the content and header tags first (before any sort of DTDs ) on the page or even by themselves.
                      - check the docs to be sure you are not using an incompatible tag on the same page ummm cflocation and cfflush i beleive..

                      here is what worked for me... the content type and filenames were stored in a database.

                      <cfquery name="update" datasource="#Application.DataSource#">
                      update files set WasDownloaded = '1' where DID = '#url.DID#'
                      <cfquery name="select" datasource="#Application.DataSource#">
                      select * from files where DID = '#url.DID#'

                      <cfheader name="Content-disposition" value="attachment;filename=#select.ServerFileName#">
                      <cfcontent type="#select.DocType#" file="#select.ServerFilePath##select.ServerFileName#" DeleteFile="No">
                      <cfcatch type="any">
                      <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" " http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
                      <html xmlns=" http://www.w3.org/1999/xhtml">
                      <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
                      <link href="/script/styles.css" rel="stylesheet" type="text/css" />

                      <table width="100%" border="0">
                      <th scope="col">An Error Has occurred. </th>
                      <td><p align="center"> </p>
                      <p align="center">An unknown error has occurred.</p>
                      <p align="center">Please report this to the <a href="mailto=#Appplication.AdminMail#">Administrator</a> </p>
                      <p align="center" class="tinytext"><a href="" onclick="window.close();">Close Window</a></p>
                      <p align="center"> </p></td>