The intention of the following code is to force a download to the client of an array of files.  The problem is that it forces out the first file but exits the loop (or leaves it hanging) and control is lost at the server side.  How can the server regain control to carry on with the loop?

<!--- STEP 1: Create Array of files to be used to force the files out to client --->
<cfset arr_filename_to_download = ListtoArray(form.File_to_download,",")>

<!--- STEP 2: Loop through array and have _javascript_ initiate the download to the client --->
<cfloop from="1" to="#ArrayLen(arr_filename_to_download)#" index="i">
<cfset filepath = arr_filename_to_download[i]>
<script language="_javascript_">
alert("File: <cfoutput>#arr_filename_to_download[i]#</cfoutput> will be deleted after it is downloaded.")
helperWindow = "window" + <cfoutput>#i#</cfoutput>
newWindow = window.open('', helperWindow)
newWindow.document.write ("<cfheader name="Content-Disposition" value="attachment; filename=#GetFileFromPath(filepath)#">")
newWindow.document.write ("<cfcontent file="#filepath#" type="application/octet-stream">")
newWindow.document.write ("<script language='_javascript_'>window.close()<\/script>")
</script>
</cfloop>
[Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]

Reply via email to