Skip to main content
nikos101
Inspiring
February 20, 2009
Question

CF to download a copy of this file

  • February 20, 2009
  • 3 replies
  • 359 views
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?

This topic has been closed for replies.

3 replies

nikos101
nikos101Author
Inspiring
February 23, 2009
I've found a way to save the text

<cffunction name="saveCSV" access="remote" returntype="void">
<cfargument name="data" type="string" required="yes">

<CFFILE ACTION='Write' file="#expandPath('../user/data.csv')#" OUTPUT='#data#'>

</cffunction>

I can then down load it using a fileReferance.

What I plan to do is save the file as a random string and allow them to download that.
Inspiring
February 20, 2009
nikos101 wrote:
> 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.

I don't think you can do that with RemoteObject:
http://blog.flexexamples.com/2007/07/28/downloading-files-in-flex-using-the-filereference-class/

--
Mack
nikos101
nikos101Author
Inspiring
February 20, 2009
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>