Skip to main content
wmkolcz
Inspiring
September 27, 2011
Answered

Force downloading page name, not file name...

  • September 27, 2011
  • 1 reply
  • 642 views

    I need some help and I think I tapped Google out as much as I can. I am attempting to write out a cvs file, then force download it. The csv generates fine, but when it comes to serving up the file as a download, it serves the name of the page instead. So rather than '10Adopt-Addresses.csv', it serves up 'addresses.cfm' with the information writen to it. I posted the code below. Thanks! 

<cfset addresses = createObject("component","com.mywebsite.adopt.adoptGateway").listAddresses(#url.orgID#) />

        <cffile action="write" file="#ExpandPath('\')#com\mywebsite\files\#url.orgID#Adopt-Addresses.csv" output="firstname,lastname,address,city,state,zip,country" addnewline="Yes">

        <cfoutput query="addresses">

            <cffile action="APPEND" file="#ExpandPath('\')#com\mywebsite\files\#url.orgID#Adopt-Addresses.csv" output="#firstname#,#lastname#,#address#,#city#,#state#,#zipcode#,#cntry#" addnewline="Yes">

        </cfoutput>       

        <cfheader name="Content-Disposition" value="#url.orgID#Adopt-Addresses.csv" />

        <cfcontent file="#ExpandPath('/')#com/mywebsite/files/#url.orgID#Adopt-Addresses.csv" deletefile="true" type="application/csv" />

This topic has been closed for replies.
Correct answer BKBK

<cfheader name="Content-Disposition" value="attachment; filename=#url.orgID#Adopt-Addresses.csv" />

1 reply

BKBK
Community Expert
BKBKCommunity ExpertCorrect answer
Community Expert
September 27, 2011

<cfheader name="Content-Disposition" value="attachment; filename=#url.orgID#Adopt-Addresses.csv" />

wmkolcz
wmkolczAuthor
Inspiring
September 27, 2011

Thanks! Just what I was missing! Worked like a charm.