PHP: Compress Files into Tar or Zip – Make A Zip File or Tar File with PHP

PHP can execute shell commands, which means it can compress selected files into a archive or zipped package:

exec('tar zcf files.tar.gz file1 file2 file3');

Or make a zip file:

exec('zip file1 file2 file3');

You can then use PHP to render and supply download of the zip file to your visitor.

Scroll to Top