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

cfzip and cfloop won't work together

New Here ,
Mar 05, 2008 Mar 05, 2008
I have a list of pdfs I want to zip up. In the first example below I try to loop over the list and put them into cfzipparams within one cfzip tag. This results in a zip file with only one pdf (the last one). In the second example I loop over the list and call the cfzip tag once for every pdf, appending each pdf separately onto the zip file. So, the second example works, but it seems to me that the first example would be more efficient if it worked. Why doesn't it work?

<cfset fileList = "somefile.pdf|anotherfile.pdf|yetanotherfile.pdf" />

The following will only add the very last pdf to the zip (yetanotherfile.pdf in my example).
<cfzip action="zip" file="#samplepath#.zip" overwrite="yes">
<cfloop index="filepath" list="#fileList#" delimiters="|">
<cfzipparam source="#filepath#">
</cfloop>
</cfzip>

The following will add all three pdfs to the zip file.
<cfloop index="filepath" list="#fileList#" delimiters="|">
<cfzip action="zip" file="#samplepath#.zip" overwrite="no">
<cfzipparam source="#filepath#">
</cfzip>
</cfloop>
701
Translate
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
Engaged ,
Mar 05, 2008 Mar 05, 2008
Your first example is only ever adding the current file definition, not adding it to a list.

It would be better to loop over the files creating a list of files to add and then run the CFZIP function
Translate
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
New Here ,
Mar 07, 2008 Mar 07, 2008
LATEST
Are you saying the cfzipparam tag can take a list of files like this:

<cfset fileList = "somefile.pdf,anotherfile.pdf,yetanotherfile.pdf" />

<cfzip action="zip" file="#samplepath#.zip" overwrite="yes">
<cfzipparam source="#fileList #">
</cfzip>

If so, that's perfect.
Translate
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