Answered
Downloading files to user
Hello!
I am using Flex front end in conjunction with CF backend to create a file, then download it to the user. The series of events is:
Flex calls the first CF page using LoadVars:
my_lv.send("filemaker.cfm","new1","POST");"
The filemaker runs a query and creates a file on the server, then calls a download page, passing it the file name like so:
<SCRIPT language="JavaScript1.2" type="text/javascript">
window.open("sendfiletouser.cfm?outputfile=<CFOUTPUT>#URLEncodedFormat(OutputFile)#</cfoutput>","new1");
</SCRIPT>
The sendfiletouser.cfm basically uses a CFHEADER/CFCONTENT combo to squirt the file to the user (obviously I set the variables properly)
<CFHEADER name="Content-Disposition" value="attachment; filename=#FileName#">
<CFCONTENT type="#MimeType#" file="#OutputFile#" deletefile="yes">
It works GREAT! Files go out exactly how they need. Except….
There is a window left behind. Yuck. I don't want to over-write the Flex ap running so I need a new window. I could use frames, creating a zero height frame to "hold" the new1 window name but I really don't want to do that. I can't write out code following the cfcontent so.....
Does anyone know how I can fix this? Or another way of sending a file out to the user from CF without leaving a window behind?
Cheers!
I am using Flex front end in conjunction with CF backend to create a file, then download it to the user. The series of events is:
Flex calls the first CF page using LoadVars:
my_lv.send("filemaker.cfm","new1","POST");"
The filemaker runs a query and creates a file on the server, then calls a download page, passing it the file name like so:
<SCRIPT language="JavaScript1.2" type="text/javascript">
window.open("sendfiletouser.cfm?outputfile=<CFOUTPUT>#URLEncodedFormat(OutputFile)#</cfoutput>","new1");
</SCRIPT>
The sendfiletouser.cfm basically uses a CFHEADER/CFCONTENT combo to squirt the file to the user (obviously I set the variables properly)
<CFHEADER name="Content-Disposition" value="attachment; filename=#FileName#">
<CFCONTENT type="#MimeType#" file="#OutputFile#" deletefile="yes">
It works GREAT! Files go out exactly how they need. Except….
There is a window left behind. Yuck. I don't want to over-write the Flex ap running so I need a new window. I could use frames, creating a zero height frame to "hold" the new1 window name but I really don't want to do that. I can't write out code following the cfcontent so.....
Does anyone know how I can fix this? Or another way of sending a file out to the user from CF without leaving a window behind?
Cheers!
