Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

CF to download a copy of this file

Enthusiast ,
Feb 20, 2009 Feb 20, 2009
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?

TOPICS
Advanced techniques
329
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Feb 20, 2009 Feb 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>
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Feb 20, 2009 Feb 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
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Feb 23, 2009 Feb 23, 2009
LATEST
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.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources