Skip to main content
Participant
April 23, 2008
Question

How to send multiple dynamically created MSWORD files to users PC

  • April 23, 2008
  • 1 reply
  • 225 views
I am looping through files loading their data, when I am done loading and creating a .doc file for env 1 I am using the cfcontent tag to send this file to the user. I then have to loop back and build all the remaining environment files. Problem is I am only asked to save the last one. Here is the code I am using.
<cfset EnvCount = 1>
<cfset FileTypeCount = 1>
<cfset limit = arrayLen(Application.EnvArray)>
<cfloop condition = "EnvCount LT limit">
<cfloop condition = "FileTypeCount LT 4">
<cfscript >
myfile = FileOpen(buildURI(),"read");
while (! FileIsEOF(myfile))
{
x = FileReadLine(myfile);
loadData(x);
}
</cfscript>
<cfset FileTypeCount = #FileTypeCount# + 1>
</cfloop>
<cfset EnvCount = #EnvCount# + 1>

<cfcontent type ="application/msword">
<cfheader name="content-disposition" value ="filename = #variables.OIG_file#">
<cfinclude template="oigoutput.cfm">
</cfloop>
    This topic has been closed for replies.

    1 reply

    Inspiring
    April 23, 2008
    A lot of browsers will now restrcit downloads to a max of 3 anyways, so the easiest way would be to write a script to zip the docs up into 1 file and then have that download instead.

    If you are using CF8, you can use the CFZIP tag.

    Unless the user has MSIE and the Office Control installed, they have to download DOC files anyway. You might as well do it as a ZIP file.

    Unless you know the users will all have Office installed, you may want to also consider using PDF files instead.