Compress a file or a directory with files.

compress(format, source, target [, includeBaseFolder] [, mode]) → returns boolean

This function requires Lucee.  Not supported on Adobe ColdFusion, etc.

Argument Reference

format string

The format in which you want to compress the files.
  • bzip
  • bzip2
  • tbz
  • tbz2
  • tar
  • tar.gz
  • gzip
  • tgz
  • zip

source string

Path (relative or absolute) to the file or directory you want to compress.

target string

Path (relative or absolute) including the name, where you want to save the compressed output-file.

includeBaseFolder boolean
Default: true

Compress the directory or just the content of the directory.

mode string
Default: 777

Sample code invoking the compress function

Compress the file "example.txt" to a zip-file.

compress("zip", "example.txt", "")

Compress the "example-directory" to a zip-file.

compress("zip", "example-directory", "")

Signup for cfbreak to stay updated on the latest news from the ColdFusion / CFML community. One email, every friday.

Fork me on GitHub