1 Reply Latest reply on Jul 12, 2006 1:04 PM by Mr Black

    Multiple cfcontent downloads via query

      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#)
      <!--- 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">
      file not found <br />


      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.

        • 1. Re: Multiple cfcontent downloads via query
          Mr Black Level 1
          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.