5
Feb
0
Web – Php unzip, zip or compress folders and files using php
I really don’t like Php. Anyway, some time it is the most easy way to act on the server. For example, to zip or unzip files. But the method I expose in this post only work on Linux/Unix because it is based on command line.
If you send 200 files and 5 folders by ftp it can take 40 minutes. But if you send a .zip and then unzip the archive file, you may spend 35 minutes less… It was what I did to uncompress the WordPress files.
Examples
- Save with .tar
<?php $archive = "save.tar"; $directory = "../SaveMePlease/"; exec( "tar cf $archive $directory"); exec( "gzip $archive"); header( 'Location: http://www.IneedToRedirectAfter.com' ) ; ?>
- Unzip
<?php $archive = "myZipFile.zip"; exec( "unzip $archive"); ?>
And After
You can look at the fallowing links to do what you really need :
http://linux.about.com/od/commands/l/blcmdl1_unzip.htm
http://linux.about.com/od/commands/l/blcmdl1_gzip.htm
Enjoyed reading this post?
Subscribe to the RSS feed and have all new posts delivered straight to you.
Subscribe to the RSS feed and have all new posts delivered straight to you.
