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

Multiple cfcontent downloads via query

Explorer ,
Jul 12, 2006 Jul 12, 2006

Copy link to clipboard

Copied

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...
TOPICS
Advanced techniques

Views

498

Translate

Translate

Report

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
Participant ,
Jul 12, 2006 Jul 12, 2006

Copy link to clipboard

Copied

LATEST
This approach will never work. Leaving details aside, the reason is that the processing of your code ends, when first CFCONTENT tag processed. There cannot be any message on your screen, if you use CFCONTENT with "FILE" attribute. Only the content of your file, which you elected to be an attachment, which triggers a download dialog on the client side.

Votes

Translate

Translate

Report

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
Documentation