Coldfusion 生成多个文件,将它们添加到zip,然后将zip作为文件下载发送。

Coldfusion 生成多个文件,将它们添加到zip,然后将zip作为文件下载发送。,coldfusion,coldfusion-9,coldfusion-8,coldfusion-10,Coldfusion,Coldfusion 9,Coldfusion 8,Coldfusion 10,我有一个生成多个电子表格对象的cfm页面,现在如果我尝试发送文件以供下载,则只发送最后生成的电子表格文件作为下载 是否有办法将这些文件写入zip并将zip文件作为下载文件发送 这是我现有的逻辑: for(VARIABLES.fileNumber = 0; VARIABLES.fileNumber < VARIABLES.maxFiles; VARIABLES.fileNumber = VARIABLES.fileNumber + 1) { /* code to create Spr

我有一个生成多个电子表格对象的cfm页面,现在如果我尝试发送文件以供下载,则只发送最后生成的电子表格文件作为下载

是否有办法将这些文件写入zip并将zip文件作为下载文件发送

这是我现有的逻辑:

for(VARIABLES.fileNumber = 0; VARIABLES.fileNumber  < VARIABLES.maxFiles; VARIABLES.fileNumber = VARIABLES.fileNumber + 1)
{
   /* code to create Spreadsheet here */




    VARIABLES.context = getPageContext();
    VARIABLES.context.setFlushOutput(true); 

    VARIABLES.response = VARIABLES.context.getResponse().getResponse();
    VARIABLES.response.reset();
    VARIABLES.response.setContentType("application/msexcel");   
    VARIABLES.response.setContentLength(len(SpreadsheetReadBinary(VARIABLES.suppItemSpreadSheetObj)));       
    VARIABLES.response.setHeader("Content-Disposition","attachment;filename=MyComplianceStatusFile#VARIABLES.fileNumber#Of#VARIABLES.maxFiles#.xls");

    VARIABLES.out = response.getOutputStream();     
    VARIABLES.out.write(SpreadsheetReadBinary(VARIABLES.suppItemSpreadSheetObj));       


    VARIABLES.out.flush();      
    VARIABLES.out.close();  
  }
for(VARIABLES.fileNumber=0;VARIABLES.fileNumber
现在,这样我只得到最后生成的电子表格。是否有一种方法可以获取生成的所有电子表格,这些电子表格可以是一个接一个的,也可以是压缩的

是的,有:。文档中有一个使用示例,但我会在这里重新编写,这样我就不会因为基本上说“RTFM”而被打耳光:



你又在用勺子喂人了。我知道,对不起。我已经厌倦了说“噢,FFS,JFGI”。我想在任何人开始写一行ColdFusion之前,他们必须被介绍给文档。或者更好的是,谷歌。@AdamCameron,几年后回到这里!很抱歉问了这个愚蠢的问题,当时我对软件开发非常陌生。顺便说一句,下载单个文件的方法更典型的是.jsp。CF中的标准(更简单)方法是使用。如果您是CF的新手,我建议您先看看和视图,以了解类似的问题。
<!--- This example shows how to zip the directory "c:\temp" into the ZIP file "e:\work\abc.zip". ---> 
<cfzip file="e:\work\abc.zip" source="c:\temp"> 

<!--- This example shows how to zip all the class files in a directory and add a subdirectory named "classes" to the JAR file entry name. ---> 
<cfzip file="e:\work\util.jar" action="zip" source="c:\src\util\" prefix="classes" filter="*.class"> 

<!---This example shows how to zip all of the log files in the ColdFusion directory and create a subdirectory called exception where zipped files are archived. 
<cfzip file="c:\zipTest\log2.zip" action="zip" source="c:\ColdFusion\" prefix="exception" filter="*.log"> 

<!--- This example shows how to overwrite all of the content of a ZIP file with the entries specified in the source. ---> 
<cfzip file="c:\currentApp.zip" source="c:\myApp\work" overwrite="yes">