Categories
PHP Tips & Tutorials

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 files.zip file1 file2 file3');

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

By Yang Yang

Hello, I'm Yang. I build online businesses that please people. Want to join in and post some useful articles on Kavoir.com? Shoot me a message.

3 replies on “PHP: Compress Files into Tar or Zip – Make A Zip File or Tar File with PHP”

Comments are closed.