Whatever message this page gives is out now! Go check it out!
delete
<cfzip
required
action = "delete"
file = "absolute pathname"
optional
entrypath = "full pathname"
filter = "file filter"
recurse = "yes|no">
list
<cfzip
required
action = "list"
file = "absolute pathname"
name = "recordset name"
optional
filter = "file filter"
recurse = "yes|no"
showDirectory= "yes|no">
read
<cfzip
required
action = "read"
entrypath = "full pathname"
file = "absolute pathname"
variable = "variable name"
optional
password = "password string"
charset = "encoding type">
readBinary
<cfzip
required
action = "readBinary"
entrypath = "full pathname"
file = "absolute pathname"
variable = "variable name"
optional
password = "password string">
unzip
<cfzip
required
action = "unzip"
destination = "destination directory"
file = "absolute pathname"
optional
maxUnzipRatio = "maximum compression ratio"
password = "password string"
entrypath = "full pathname"
filter = "file filter"
overwrite = "yes|no"
recurse = "yes|no"
storePath = "yes|no">
zip
<cfzip
required
file = "absolute pathname"
One of the following:
source = "source directory"
<cfzipparam source = "source directory" ...>
optional
encryptionAlgorithm = "standard|AES-128|AES-256"
password = "password string"
action = "zip"
filter = "file filter"
overwrite = "yes|no"
prefix = "string"
recurse = "yes|no"
storePath = "yes|no"><cfscript>
// delete
cfzip(action = "delete", file = "absolute pathname", entrypath = "full pathname", filter = "file filter", recurse = "yes|no")
</cfscript><cfscript>
// list
cfzip(action = "list", file = "absolute pathname", name = "recordset name", filter = "file filter", recurse = "yes|no", showDirectory= "yes|no")
</cfscript><cfscript>
// read
cfzip(action = "read", entrypath = "full pathname", file = "absolute pathname", variable = "variable name", password = "password string", charset = "encoding type")
</cfscript><cfscript>
// readBinary
cfzip(action = "readBinary", entrypath = "full pathname", file = "absolute pathname", variable = "variable name", password = "password string")
</cfscript><cfscript>
// unzip
cfzip(action = "unzip", destination = "destination directory", file = "absolute pathname", password = "password string", maxUnzipRatio ="maximum compression ratio", entrypath = "full pathname", filter = "file filter", overwrite = "yes|no", recurse = "yes|no", storePath = "yes|no")
</cfscript><cfscript>
// zip
cfzip(file = "absolute pathname", source = "source directory"
(cfzipparam source = "source directory"..),
encryptionAlgorithm = "standard|AES-128|AES-256", password = "password string", action = "zip", filter = "file filter", overwrite = "yes|no", prefix = "string", recurse = "yes|no", storePath = "yes|no")
</cfscript>Attribute | Action | Req/Opt | Default | Description |
action | N/A | Optional | zip | Action to take. Must be one of the following:
|
charset | read | Optional | default encoding of the host machine | Character set used to translate the ZIP or JAR entry into a text string. Examples of character sets:
|
destination | unzip | Required | Destination directory where the ZIP or JAR file is extracted. | |
entryPath | deletereadreadBinaryunzip | Optional | Pathname on which the action is performed. | |
file | deletelistreadreadBinaryunzipzip | Required | Absolute pathname of the file on which the action is performed; for example, the full pathname of the ZIP file: c:\temp\log.zip. If you do not specify the full pathname (for example, file="log.zip"), ColdFusion creates the file in a temporary directory. You can use the GetTempDirectory function to access the ZIP or JAR file. | |
filter | deletelistunzipzip | Optional | File filter applied to the action. The action applies to all files in the specified pathname that match the filter. | |
name | list | Required | Record set name in which the result of the list action is stored. The record set columns are the following:
| |
overwrite | unzipzip | Optional | no | unzip: Specifies whether to overwrite the extracted files:
|
prefix | zip | Optional | String added as a prefix to the ZIP or JAR entry. The string is the name of a subdirectory in which the entries are added. | |
recurse | deletelistunzipzip | Optional | yes | Specifies whether the action applies to subdirectories:
|
showDirectory | list | Optional | no | Specifies whether to show the directory structure:
|
source | zip | Required (see description) | Source directory to be zipped. Not required if the cfzipparam tag is specified. | |
storePath | unzipzip | Optional | yes | unzip: Specifies whether files are stored at the entry path:
|
variable | readreadBinary | Required | Variable in which the content is stored. | |
| password | zip | Optional | The password to be used for the archive. | |
| encryptionAlgorithm | zip | Optional | The encryption algorithm to use for compression. The following options are valid:
If the attibutes are specified in the CFZip tag, they can be inherited or overridden by the corresponding attributes in the CFZipparam tag. If only password is provided, the default encryptionAlgorithm will be AES 256-bit. If used with a directory, all files in that directory will be protected with the same password/encryption. |
maxUnzipRatio | unzip | Optional | 100 | Used when the compression ratio of file is more that 100. |
ram:///filepath--->
<cfzip file="e:\work\soure.jar" action="delete" filter="*.properties, *.props">
<!--- This example shows how to delete all of the entries in a ZIP file with a JPG, GIF, or PNG extension, including entries in subdirectories. --->
<cfzip file="c:\myApp\images.zip" action="delete" filter="*.jpg, *.gif, *.png" recurse="yes">
<!--- This example shows how to delete the "images" subdirectory (and its contents) from the "myApp.zip" file. --->
<cfzip action="delete" file="c:\myApp.zip" entrypath="images">
<!--- This example shows how to delete all Java source entries in the "work/source" directory and images (*.gif, *.jpg, *.jpeg) from a JAR file. --->
<cfzip file="C:\downloads\source.jar" action="delete">
<cfzipparam entrypath="work/source" filter="*.java">
<cfzipparam filter="*.gif,*.jpg,*.jpeg">
</cfzip>Field | Description |
comment | Text string description saved with the entry source. |
compressedSize | Compressed size of the entry in bytes. |
crc | Checksum for the entry source. |
dateLastModified | Date and time when the source was last modified. |
directory | Name of the directory where the entry is stored. |
name | Entry pathname. |
size | Uncompressed size of the entry source in bytes. |
type | Source type for the entry, for example, file. |
<cfzip file="c:/myApp.jar" action="list" name="entry">
<cfdump var="#entry#"><table>
<cfoutput>
<tr>
<td><b>Entry Name:</b> #entry.name#</td>
<td><b>Last Modified Date:</b> #dateFormat(entry.dateLastModified)#,#timeFormat(entry.dateLastModified)#</td>
<td><b>Size (uncompressed):</b> #numberFormat(entry.size/1000)# KB
<br></td>
</cfoutput>
</tr></table><cfzip action="read" file="/home/sam/work/util.jar" entrypath="info.txt" variable="text"><cfzip file="c:\work\instr.zip" action="readBinary"
entryPath="com/test/abc.jpg" variable="xyz">
<cfzip file="c:\work\copy_instr.zip">
<cfzipparam entryPath="com/test/xyz.jpg" content="#xyz#">
</cfzip><cfzip file="e:\work\tools.jar" action="unzip" filter="*.class" destination="c:\temp\tools\classes"/>
<!--- This example shows how to extract files from a JAR file in multiple directories. --->
<cfzip file="e:\work\images.jar" action="unzip" destination="c:\images">
<cfzipparam entryPath="toWork\small">
<cfzipparam entryPath="final\large">
</cfzip><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"><cfquery name="artist" datasource="cfartgallery">
SELECT FIRSTNAME || ' ' || LASTNAME AS FULLNAME,ARTISTS.ARTISTID
FROM ARTISTS
</cfquery>
<!--- Create a form that lists the artists generated by the query. --->
<cfform action="zipArt_action.cfm" method="post">
<h3>Choose an Artist</h3>
<p>Please choose an artist:</p>
<cfselect name="artistName" query="artist" display="FULLNAME" value="ARTISTID" required="yes" multiple="no" size="8">
</cfselect>
<br/><cfinput type="submit" name="submit" value="OK">
</cfform><cfquery name="artwork" datasource="cfartgallery">
SELECT FIRSTNAME, LASTNAME, LARGEIMAGE
FROM ARTISTS, ART
WHERE ARTISTS.ARTISTID = ART.ARTISTID
AND ARTISTS.ARTISTID=<cfqueryparam value="#form.artistName#">
ORDER BY ARTNAME
</cfquery>
<cfoutput>
<p>You have chosen the work of #artwork.FirstName# #artwork.LastName#.</p>
<cfset thisDir = ExpandPath(".")>
<cfset imgDir = ExpandPath("..")>
</cfoutput>
<cfset xctr = 1>
<table border="0" cellpadding="15" cellspacing="0" bgcolor="#FFFFFF">
<cfoutput query="artwork">
<cfif xctr mod 3 eq 1>
<tr>
</cfif>
<!--- Use the IsImageFile function to verify that the image files
extracted from the database are valid. Use the ImageNew function to
create a ColdFusion image from valid image files. --->
<cfif IsImageFile("#imgdir#/cfdocs/images/artgallery/
#artwork.largeImage#")>
<cfset myImage=ImageNew("#imgdir#/cfdocs/images/artgallery/
#artwork.largeImage#")>
<td valign="top" align="center" width="200">
<cfset xctr = xctr + 1>
<img src="#imgdir#/cfdocs/images/artgallery/#artwork.largeImage#"/>
</td>
<!---Zip the files by the specified artist. --->
<cfzip source="#imgDir#/cfdocs/images/artgallery/#artwork.LARGEIMAGE#"
action="zip" file="#thisDir#/#artwork.lastname#.zip">
</cfif>
</cfoutput>
</tr>
</table>
<h3>Mail the ZIP File</h3>
<p>Please enter your e-mail address so we can send you the ZIP file as an attachment.</p>
<cfform action = "zipArt_action2.cfm" method="post">
Your e-mail address: <cfinput type = "Text" name = "MailTo">
<!--- Specify the required field. --->
<cfinput type = "hidden" name = "MailTo_required" value = "You must enter
your email address">
<cfinput type="hidden" name="zipPath"
value="#thisDir#/#artwork.lastname#.zip">
<p><cfinput type = "Submit" name = "OK" label="Mail">
</cfform><h3>Mail the ZIP file</h3>
<p>Your file has been mailed to you.</p>
<cfset eMail="#form.MailTo#">
<cfset zipPath="#form.zipPath#">
<cfmail from="coldfusion@adobe.com" to="#eMail#" subject="see zipped attachment">
The images you requested are enclosed in a ZIP file.
<cfmailparam file="#zipPath#">
</cfmail>