Filename in CFHeader

I'm using the following to export a CSV file:
<cfheader name="Content-Disposition" value="attachment;filename=download.csv">
<cfcontent type="text/csv" reset="yes"><cfoutput>#variables.output#</cfoutput>
This works fine in IE, but in FF the filename comes out as "download.csv," with a trailing comma, and in Chrome as "download.csv, attachment".  Because of this Excel doesn't recognize it.  Why is the filename not coming out as instructed?  I believe this has worked fine in the past, but not in this particular case.

Try using Excel's type instead, namely
<cfcontent type="application/vnd.ms-excel">
What happens?

Similar Messages

  • CF to download a copy of this file

    I'm making Flex call a remote object on CF and I want CF to
    download a copy of this file as onto the users file system. Is this
    possible in my method?

    I've tried this code but the file doesn't seem to download.
    It gets saved to the server ok though.
    <cffunction name="downloadCSV" access="remote"
    returntype="void">
    <cfargument name="data" type="string" required="yes">
    <CFFILE ACTION='Write'
    file="#expandPath('../userData/data.csv')#" OUTPUT='#data#'>
    <cfset yourFileName="data.csv">
    <cfcontent type="application/x-unknown">
    <cfheader name="Content-Disposition"
    value="attachment;filename=#yourFileName#">
    <cfheader name="Content-Description" value="This is a
    tab-delimited file.">
    <cflocation
    url="#expandPath('../userData/data.csv')#">
    </cffunction>

  • CFContent failing on large files since moving to ColdFusion 9

    Keep getting "The website canno display the page". It is ok when the file is 50MB, but when 300MB or above  - it failed.
    It worked on CF8. We migrated to CF9 during the weekend and all the settings are the same.
    I found that several CF users ran into similar issue - so I know it's not only me like Dan, Tom, etc (http://www.mail-archive.com/[email protected]/msg348532.html//www.mail-archive.com/[email protected]/msg348532.html)
    Thanks,
    Pat.

    This has caused me a bit of a nightmare. When you upgrade versions, you expect things to at least improve. This has to be a priority fix - it's a howling problem!
    Anyhow, for the benefit of others in a similar situation, I eventually got around this by creating a read-only FTP account (literally read-only - the user can't even list files/directories) on our web server and then I use a cflocation redirect instead of the cfcontent approach to serve up the file. I use UUIDs as folder names, so it's a pretty safe way of stopping people from downloading content they shouldn't.
    So, instead of this...
    <cfset Path = "#pathToMyFile#\#myFileName#">
    <cfset FileInfo = GetFileInfo(Path)>
    <cfset FileSize = FileInfo.size>
    <cfset MimeType = getPageContext().getServletContext().getMimeType(Path)> <!--- Sometimes doesn't work, so we need to check that MimeType exists below --->
    <cfheader name="Content-Disposition" value="attachment; filename=""#myFileName#""">
    <cfheader name="Expires" value="#Now()#">
    <cfheader name="Content-Length" value="#FileInfo.size#">
    <cfif IsDefined("MimeType")>
         <cfcontent type="#MimeType#" file="#Path#" deletefile="No">
    <cfelse>
         <cfcontent type="application/octet-stream" file="#Path#" deletefile="No">
    </cfif>
    I now have this...
    <cfset FTPDownloadLink = "ftp://[email protected]/myFTPPath/#myFileName#//[email protected]/myFTPPath/#myFileName#">
    <cflocation url="#FTPDownloadLink#" addtoken="no">
    I suspect that this is actually a better way of doing things anyway, since it offloads responsibility to serving the file from the CF server to the FTP, which is, after all, what it is designed to do.

  • How can I make the browser use the proper filename during a forced save, using CFCONTENT/CFHEADER

    We have a client using CF8 Server for a site and I am using the CFHEADER/CFCONTENT method to force a file to save to the end-user's computer.
    The dialogue comes up as expected, but regardless of what is found in the CFHEADER for a filename, it tries to save the file as the CFM page name.
    i.e. The CFM page is signature.cfm. I am trying to make it save a TXT file to the user's computer, which it seems to be trying to do, but the instead of using "sig.txt" as the filename as outlined in the CFHEADER, it is defaulting to "signature.cfm"
    While I know that I could change the name and extension and the content in the file would be correct, the mass majority of end-users will not know that they can do that, and the client does not want it to become more complicated than necessary.
    Is there a way to make the file change to the proper name in the SAVE AS dialogue?
    Thanks in advance.
    Code so far is pretty straight forward ...
    <CFHEADER name="Content-Disposition" value="attachment; filename=sig.txt">
    <CFCONTENT type="application/unknown" file="#xf#">

    I'm guessing the type="application/unknown" is interfering. Try type="text/plain".

  • CFContent open file with # in filename

    I am trying to launch a file when the user clicks on a link. Sometimes the filename has a # sign in the name, like "My File #1.xlsx". When they click it, they get an error saying "The file specified in the contentTag does not exist" and then the shows .../My File not found.
    Additionally, though I can't remember for sure at the moment, I think I've had trouble with a few other characters such as  ^, *, ?, ", <, >, |. And consecutive periods (.) like My...Filename.xlsx. However, I can live with that problem but not the # in the filename!
    Surely there's something I can do to launch such a file.
    Here's what I'm using:
    this is the call: <td><a href="./fileopener.cfm?attached_file=true&file_location=#qryGetFileNames.ServerDirectory# \#qryGetFileNames.ServerFile#">#qryGetFileNames.ServerFile#</a></td>
    <cfset file_location = "#url.file_location#">
    <cfheader name="content-disposition" value="attachment;filename=#file_location#">
    <cfcontent deleteFile="no" file=#file_location# reset="yes">
    Thank you.

    Have you tried escaping the # ?
    #replace(file_location,"#","##","all")#
    OR
    In the URL: #URLEncodedFormat(qryGetFileNames.ServerFile)#
    ^_^

  • Load pdf with cfheader and cfcontent

    I have the following code to load a PDF.
    <cfquery datasource="lamtra1_data1" name="getpdf">
    Select * from lamtracpdf WHERE id=#url.id#
    </cfquery>
    <cfoutput query="getpdf">
    <cfheader name="Content-Type" value="pdf">
    <cfheader name="Content-Disposition" value="inline;
    filename=D:\hshome\lamtrac1\pdf\#filename#">
    <cfcontent type="application/pdf"
    file="D:\hshome\lamtrac1\pdf\#filename#" deletefile="No">
    </cfoutput>
    The problem I have is that the browser load the entired PDF
    before open it. I would like to have the first page to load so the
    user can start seeing the document while the rest of the pdf is
    downloading... i do not want the pdf index in the search engine
    because its confidential information so i have put the files before
    the domain root. So I have to go with the code above to make it
    load. The PDF is format correctly because if I load it from the
    root it work correctly because it open right in acrobat reader but
    in the way I did it the acrobat reader open in the browser thats
    why i have to wait until the entired document have download before
    starting viewing it... anybode have a solution for me please help
    help????????

    mbdooly wrote:
    > Hello all-
    > I am having an issue with the tags cfheader and
    cfcontent. This is the code I
    > am using:
    >
    > <cfheader name="Content-Disposition"
    value="filename=Jurisdictionary.exe">
    Try value="attachment; filename=""Jurisdictionary.exe"""
    Mack

  • Cfcontent/cfheader doesn't support file pause/resume.

    I'm testing the possibility of using cfcontent to serve my file downloads for security purposes. Files in the web root seem to be open to all on the web but I can use cfcontent to serve files from an otherwise unaccessable directory. The downloads are working great but they cannot be paused or resumed in a download manager. Am I doing something wrong or what?
    Here's my code;
    <cfif isdefined('url.downloadpath')>
        <cfheader name="Content-Disposition" value="attachment; filename=#replace(url.filename,' ','_','all')#">
        <cfheader name="Content-Length" value="#url.filesize#">
        <cfheader name="Content-Type" value="application/octet-stream">
        <cfheader name="Content-Location" value="./?#query_string#">
        <cfcontent type="application/octet-stream" file='#url.downloadpath##url.filename#'>
        <cflocation addtoken="no" url="./?#left(query_string,find('&downloadpath')-1#">
    </cfif>
    Thanks,
    Jon

    Where did you learn that turning the iPod off and later turning it on takes more power from the battery than leaving it in sleep mode? I'm not saying that you are wrong, just interested where this info came from.

  • Redirect after using cfheader/cfcontent

    I have a file that a user is prompted to download using
    <cfheader
    name="content-disposition"
    value="attachment; filename=ProPlannerRevenueTemplate.xls"
    />
    <cfcontent
    type="image/jpeg"
    file="#ExpandPath(
    './download_templates/ProPlannerRevenueTemplate_#Left(Hash(session.client_id),
    15)#.xls' )#"
    deletefile="yes" />
    Afterwards, I want to redirect the user to another page, but
    the <cflocation> tag I have after this doesn't seem to
    execute. Any ideas on how to restructure this so that it will
    work?

    I do not think you can do these two operations with the same
    request. A
    <cflocation...> works by sending a client a HTTP status
    of 302 FOUND
    (Moved Temporarily). If the client acted on this status it
    would move
    to the specified URL and not download the file. OR it does
    not act on
    this status and receives this response.
    What you are attempting to do, is probably best done with
    some client
    side code. That uses JavaScript to relocate the client once
    this
    response is received.
    Why this is not currently relocating and sending the file is
    probably
    because of the default reset="yes" parameter of the
    <cfcontent...> tag
    that discards any response generated before the tag.

  • Cfheader /CFcontent producing inconsistent results

    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

    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">

  • CFheader and CFContent

    Hello all-
    I am having an issue with the tags cfheader and cfcontent.
    This is the code I am using:
    <cfheader name="Content-Disposition"
    value="filename=Jurisdictionary.exe">
    <cfcontent type="application/octet-stream"
    file="c:\windown\Jurisdictionary.exe">
    The issue is that my file is not being renamed correctly, I
    keep getting a file with the extension of 'EFW'.
    This did work at one time as I had been provided with thte
    mime type of "octet-stream" but now that is not working, has anyone
    got a solution or a site where I can get more info?
    Thanks a bunch, you are all the very best there is and many
    thanks to you in the past!!
    Respectfully
    MIke Dooly

    mbdooly wrote:
    > Hello all-
    > I am having an issue with the tags cfheader and
    cfcontent. This is the code I
    > am using:
    >
    > <cfheader name="Content-Disposition"
    value="filename=Jurisdictionary.exe">
    Try value="attachment; filename=""Jurisdictionary.exe"""
    Mack

  • CFHEADER & CFCONTENT to dowload a file

    Hello everybody,
    There are two buttons on my page and depending on which is clicked the code chooses to download either Report_1 or Report_2:
    <cfif Form.i_hdn_rpt_1 GT 0>
    <CFHEADER NAME="Content-Disposition" VALUE="inline; filename=rpt_1.csv">
    <CFCONTENT TYPE="application/csv">rpt_1,1,1<cfabort>
    </cfif>
    <cfif Form.i_hdn_rpt_2 GT 0>
    <CFHEADER NAME="Content-Disposition" VALUE="inline; filename=rpt_2.csv">
    <CFCONTENT TYPE="application/csv">rpt_2,2,2<cfabort>
    </cfif>
    Now what's happening. Say, I click Report_2. It offers (as expected) to download the file rpt_2.csv. Then if I click Report_1 it downloads rpt_1.csv. So far so good. But after this regardless of what is clicked (Report_1 or Report_2) it downloads rpt_1.csv only.
    If I begin with Report_1 then no way can I force to download rpt_2.csv.
    Could anybody tell me what I am doing wrong?
    Thanks,
    Alex

    Hi BKBK,
    Thanks for your response. Here is the simplified code of the form along with the JS function which assigns values to the hidden vars.
    function set_hidden(inHdnVarID)
      var oHdn = document.getElementById(inHdnVarID);
      oHdn.value = 1;
    <cfform name="myFrm" id="myFrm" action="RptPage.cfm" method="post">
      <table>
        <tr>
          <td>
            <input type="submit" name="sbtn_submit" id="sbtn_submit" value="rpt_1" onclick="set_hidden('i_hdn_rpt_1'); return false">
          </td>
          <td>
            <input type="submit" name="sbtn_submit" id="sbtn_submit" value="rpt_2" onclick="set_hidden('i_hdn_rpt_2'); return false">
          </td>
        </tr>
      </table>
      <input type="hidden" name="i_hdn_rpt_1" id="i_hdn_rpt_1">
      <input type="hidden" name="i_hdn_rpt_2" id="i_hdn_rpt_2">
    </cfform>
    There is another thing I've noticed. If I change the sequence of the pieces in CF code so that the report_2 comes first then it's the report_2 which gets dowloaded regardless of what button is clicked:
    <cfif Form.i_hdn_rpt_2 GT 0>
    <CFHEADER NAME="Content-Disposition" VALUE="inline; filename=rpt_2.csv">
    <CFCONTENT TYPE="application/csv">rpt_2,2,2<cfabort>
    </cfif>
    <cfif Form.i_hdn_rpt_1 GT 0>
    <CFHEADER NAME="Content-Disposition" VALUE="inline; filename=rpt_1.csv">
    <CFCONTENT TYPE="application/csv">rpt_1,1,1<cfabort>
    </cfif>
    Any ideas?
    Thanks again,
    Alex

  • Cfheader works with firefox or opera, but not with IE. why?

    Good morning at all.
    i have a problem with Internet Explorer and the download of a
    excel file created by filling a table with the result of a query.
    how it work?
    click button => call create_excel.cfm =>
    <cfheader name="Content-Disposition" value="attachment;
    filename=#dbtest#.xls">
    <cfcontent type="application/vnd.ms-excel" reset="yes"
    >
    <cfoutput>
    <cfloop query_with_data>
    <....
    table ...
    </cfloop>
    <cfoutput>
    with firefox or opera, all version, when i click the button
    witch call the page that create the excel file, i obtain the excel
    file correctly.
    If i use Internet Explorer,
    the first click on the button says : (Italian to english
    translation)
    Impossible to download create_excel.cfm the I DO NOTHING and
    the second time that i click on the SAME BUTTON i obtain the
    correct xls file!
    i'm not able to solve =(
    any idea?
    thanks
    bye!

    Hi Gary,
    It's probably just because the border widths you are specifying are too small (or WebKit is interpreting picas differently to Firefox/IE - I say WebKit as the same problem is visible in Google Chrome and that uses WebKit like Safari as well).
    Try setting using this instead:
    .borders {
    font-family: Verdana;
    font-size: 10px;
    font-style: normal;
    font-weight: normal;
    font-variant: normal;
    color: #cccccc;
    text-decoration: none;
    border: 1px solid #888888;
    That seems to do the trick for Firefox and Chrome on this Linux machine I'm using at the moment.

  • Coldfusion 11 cfheader or cfcontent 'failed to load PDF document'

    I have a website that worked fine with Coldfusion 10 and now I have updated to Coldfusion 11 and this code doesn't work:
    <cfheader name="content-disposition" value="inline; filename=#vPublicFile#" />
    <cfcontent type="application/pdf" file="#DownloadFolder##qryDownload.fileNameOnserver#" deleteFile="no" />
    If I type in the URL directly to the PDF file it loads fine, but if I try to get it through this code then I get the message "failed to load PDF document".  Even if I change the code to allow me to save the file, I get a saved file but it won't open in acrobat.
    I know the code is working code, I tried it with Coldfusion 10 again just to make sure.  Something about 11 is stopping it from working.  Any ideas?

    I think that this is a iis web connector issue.
    One of the worst cf update bugs I have ran into.
    I have a lot of binary data served up with cfcontent, I never include "index.cfm," and almost always have query string params.
    <cfheader name="Content-Length" value="#variables.FileSizeBytes#" />
    <cfheader name="Content-Disposition" value="inline;filename=#variables.FileName#" /> (inline vs attachment makes no difference)
    <cfcontent type="application/pdf" file="#variables.File#" />
    /test/  - works
    /test/index.cfm  - works
    /test/index.cfm?getPDF=1  - works
    /test/?getPDF=1  - fails
    Connection:close response header value there everytime it fails:
    Connection:close
    Content-Disposition:inline;filename=abcd.pdf
    Content-Length:31739
    Content-Type:application/pdf;charset=UTF-8
    Date:Wed, 12 Nov 2014 20:59:55 GMT
    Server:Microsoft-IIS/7.5
    Response headers when it works:
    Content-Disposition:inline;filename=abcd.pdf
    Content-Length:31739
    Content-Type:application/pdf;charset=UTF-8
    Date:Wed, 12 Nov 2014 20:55:53 GMT
    Server:Microsoft-IIS/7.5

  • Logical filename in broadcasting

    Hi everyone,
    We want to use the bursting functionality to broadcast a report to the portal. We'll split the result to profit center so each profit center gets a seperate pdf document. Now a few hundred pdf files get created but it's unclear which file containts data for which profit center (without opening each file). Is there a way to add the profit center to the filename of the pdf document created? We've lookad at the variable on filename creation but these are not sufficient.
    Kind regards,
    Alex

    Hi Alex,
    I've found a discussion between SAP dev and another customer... where dev refers to the following...
    Filename: (Mandatory) this name is used for the directory name. This
    name is also the technical name of the directory in the database. The
    query_name/tempalate name is taken as default.
    "Display Name: If provided, replaces the Filename for user display on
      the portal.
    If a control query is used (which may generate multiple files), then
    the end files are names based on query_name/tempalate name + index."
    Do you have the option of a display name?
    Please read the following...
    Broadcast to the Portal 
    http://help.sap.com/saphelp_nw70ehp1/helpdata/en/29/f50b40c6c01961e10000000a155106/content.htm
    I hope this helps
    thanks
    Orla.

  • In Photoshop Express, cannot sort images in album by filename in thumbnail view (for slideshow)l.

    In Photoshop Express, I want images to appear sorted by filename.  In the "view as a table" it sorts fine.  When I revert to the thumbnail view, the arrangement is random.  The dropdown "show" list does not offer an option for showing by filename.  If I select the"custom" option, it means I would need to sort 300 images by filename MANUALLY (!!!), a job that a computer does in milliseconds.  Anyone with a solution?  Thanks.

    fwiw, with my images in the 'Folder Location' view the photos are in order by their Windows filename. That is the same order as the hardcopy album the photos came from. So I then created a PSE Album. I selected all my photos and moved them into that album. The order of the pictures was retained in the Album. That worked out great. I wanted my PSE images to be in the same order. I thought I would do it with tags. But creating an album seems to work just fine.

Maybe you are looking for

  • Camera raw images change colour in adobe bridge

    I have photoshop CS4 and import my camera raw images into Adobe Bridge.  When I view the thumbnails in bridge my raw images look vibrant and exactly like they appear on the camera but when I go to open them in camera raw edit they change colour and l

  • Sanyo Phone always mounts read-only

    I recently purchased a Sanyo M1 phone that has a USB mass storage mode. The phone has 1GB of internal memory that is formatted with FAT16. When connected via a USB cable, a "SANYO" drive appears on the desktop, and is labeled "/Volumes/SANYO". This d

  • Why file.delete() won't work?

    I looked throught the forum and I have seen that my problem isn't the most uncommon one. I'm trying to delete a file using file.delete().But it always return false. I have used the file for reading(and sometimes writing) before but I have closed the

  • Problems Flex & Java

    Hi I´m trying to develop a Stock Portfolio Application that is this site´s sample: http://java.sys-con.com/read/210991.htm When I was wrinting the ActionScript code that's used on the client (listing 5 from http://res.sys-con.com/story/apr06/210991/s

  • I am upgrading from Snow Leopard 10.6.8 to Mavericks and the download is waiting.  I do not have Launchpad.  How do I resume the download?

    I have been able to find documentation about resuming the Mavericks download using LaunchPad but unable to find a workaround without LaunchPad.