Using CFHeader and CFContent to control file downloads

Ask a Question related to Coldfusion - Advanced Techniques, Design and Development.

  1. #1

    Default Using CFHeader and CFContent to control file downloads

    I am programming a CF application for an online university. They need to be
    able to upload files to the server, and then authorize students individually as
    to which files they can download. I've got this part written. Fortunately I
    do have access to CFFile and CFDirectory tags, perfect for uploading. But the
    problem comes in downloading. When I use CFHeader and CFContent to download
    the file, I get unpredictable results. For instance, if the file is an MP3, it
    streams in and plays on my IE, but allows me to save it on Netscape. If the
    file is a PDF, it tries to load into my IE (and fails) but Netscape lets me
    save it do disk. Obviously, this is not an acceptable solution. Please note
    that in all cases, I do NOT want the file to stream or open inside a browser.
    I want it to save on the user's computer. Am I using these two tags wrong? Or
    are they so basic that they are unreliable for controlling downloads across
    browsers? It seems a shame that uploads can be controlled so perfectly, but
    downloading is sort of hit-or-miss. Any suggestions anyone?

    Zy Forever Guest

  2. Similar Questions and Discussions

    1. problem downloading using CFCONTENT & CFHEADER
      I am running into the same problem. Please reply if you find any fix to this problem. Thanks
    2. cfcontent ,cfheader download
      i am sending an email to users in which there is a link for the coldfusion template , cfm page downloads the pdf file from the server , ...
    3. MIMEtype and Cfheader/Cfcontent
      Hello all, We are using cfheader and cfcontent with a custom tag to hide the url of our downloadable files. We also have an exception page set to...
    4. CFHEADER, CFCONTENT, Acrobat 6.0 and InternetExplorer problem...
      Originally posted by: cf_menace This works perfectly with Acrobat 6.0 and MSIE 6.0. The key to getting the PDF plug-in to save the PDF as the...
    5. Control File downloads?
      I wish to control the number of files a web viewer can download say in a given time eg 1 minute,1 hour, Day etc to ease congestion. Whats the...
  3. #2

    Default Re: Using CFHeader and CFContent to control filedownloads

    When you specify the correct mime-type, the user's browser takes over whatever
    default action the user has specified for that type of file.

    IIRC, if you set mime-type="application/unknown" for all file types, you
    should always get the "Save As" dialog box.

    cf_menace Guest

  4. #3

    Default Re: Using CFHeader and CFContent to control filedownloads

    Thanks for the swift reply, cf_menace. Unfortunately, what it should do and
    what it does are two different things. Here is my code: <cfheader
    name='Content-Disposition' value='filename=#GetFile.FileName#'> <cfcontent
    type='application/unknown' file='#RootDirectory#\#GetFile.FileName#'> This
    produces the exact behavior I described above: sound files stream and play,
    pdf files attempt to load into the browser. I do not get 'Save As' dialogue in
    IE. I have tried changing it to mime-type='application/unknown', but cfcontent
    in cf 4.5 won't accept mime-type as a parameter. So, not knowing what I'm
    doing, I also tried type='mime-type=application/unknown' and
    type='mime/application/unknown' ... neither of which worked. Is there another
    way to code this? I've considered getting CFX_Zip and zipping each file before
    it downloads. I'm pretty sure that a zipped file would have to evoke the 'Save
    As' dialogue. What else would a browser do with it? I don't know if CFX_Zip
    works with CF 4.5 though. However, if there is a cf solution without the
    custom tag, I'd sure like to know about it.

    Zy Forever Guest

  5. #4

    Default Re: Using CFHeader and CFContent to control filedownloads

    Try
    <cfheader name="Content-Disposition" value="inline; filename=#GetFile.FileName#">
    or
    <cfheader name="Content-Disposition" value="attachment; filename=#GetFile.FileName#">
    cf_menace Guest

  6. #5

    Default Re: Using CFHeader and CFContent to control filedownloads

    Hi cf_ ... You are the greatest! The first option did not work. The second
    one did: <cfheader name='Content-Disposition' value='attachment;
    filename=#GetFile.FileName#'>I marked your post above as question answered.
    Thank you so much! Zy

    Zy Forever Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139