Copy link to clipboard
Copied
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" />
<cfheader name="Content-Disposition" value="attachment; filename=#url.orgID#Adopt-Addresses.csv" />
Copy link to clipboard
Copied
<cfheader name="Content-Disposition" value="attachment; filename=#url.orgID#Adopt-Addresses.csv" />
Copy link to clipboard
Copied
Thanks! Just what I was missing! Worked like a charm.