Database has a field for file names; files are stored in
separate folder. Query is run to grab selected records, getting the
filenames to download. A CFOUTPUT query is used to download the
files with a CFCONTENT command.
Only the first file in the CFOUTPUT query causes the
open/save dialog box on user's computer. Subsequent files specified
in the query are not downloaded (no open/save dialog box).
Code is here:
<cfquery name="DocumentFileList"
datasource="CityClerk_Documents">
SELECT docfilename FROM documents
WHERE DOCUMENTNUMBER IN (#session.docnumberchecked#)
</cfquery>
<!--- session.docnumberchecked is ID number field of
selected records, as in "12,15,30" -->
<cfoutput query="DocumentFileList"> <!-- query loop
--->
<cfset getfilename = DocumentFileList.docfilename>
<!--- grab the filename value --->
<cfset filepath = "D:\DocRoot\#getFileName#"> <!---
where the file lives ---->
<cfif fileexists("#filepath#") EQ "true"> <!---
check if file exists there --->
file found<br />
<!--- get the file for dowload --->
<cfheader name="Content-Disposition" value="attachment;
filename=#getFileFromPath(filePath)#">
<cfcontent file="#filePath#"
type="application/octet-stream">
<cfelse>
file not found <br />
</cfif>
</cfoutput>
QUestions:
1) How to use cfquery to loop through the files to download.
2) Any text on that page (like "file found") is not
displayed. When the page loads, the open/save dialog is shown, not
any other page content.
Thanks...Rick...