How can ColdFusion work with ZIP and JAR files?

Use the <cfzip> and the <cfzipparam> tags.

<cfzip> provides access to ZIP and JAR files with the following actions:

delete: Deletes one or more files from the file.

list: Lists the contents of the file.

read: Reads the contents of the file into a variable.

readBinary: Reads the contents of a binary archived file into a variable.

unzip: Extracts files from the ZIP or JAr file.

zip: Compress files into a ZIP or JAR file.

<cfzip file="c:/foo.jar" action="list" name="myVar">
<cfdump var="#myVar#">

Use the <cfzipparam> tag with the <cfzip> tag to zip, extract, or delete multiple files or directories. For example:

<!--- This example shows how to update a ZIP file with files from multiple locations, each with a different filter. --->
<cfzip file="c:\foo.jar" action="zip">
 <cfzipparam source="c:\test1\file1.txt">
 <cfzipparam source="c:\test2\test3" recurse="yes">
</cfzip>

This question was written by Jeremy Petersen
It was last updated on December 12, 2007.

Categories

File and Directory Access

Comments

comments powered by Disqus