Ver Mensaje Individual
  #18 (permalink)  
Antiguo 11/07/2011, 08:51
Avatar de abimaelrc
abimaelrc
Colaborador
 
Fecha de Ingreso: mayo-2009
Ubicación: En el planeta de Puerto Rico
Mensajes: 14.734
Antigüedad: 15 años
Puntos: 1517
Respuesta: Comprimir directorio entero

En este artítulo, http://devzone.zend.com/article/2105 existe un buen material para que te puedas desenvolver, específicamente con
Código PHP:
Ver original
  1. <?PHP
  2. // increase script timeout value
  3. ini_set('max_execution_time', 300);
  4.  
  5. // create object
  6. $zip = new ZipArchive();
  7.  
  8. // open archive
  9. if ($zip->open('my-archive.zip', ZIPARCHIVE::CREATE) !== TRUE) {
  10.     die ("Could not open archive");
  11. }
  12.  
  13. // initialize an iterator
  14. // pass it the directory to be processed
  15. $iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator("app/"));
  16.  
  17. // iterate over the directory
  18. // add each file found to the archive
  19. foreach ($iterator as $key=>$value) {
  20.     $zip->addFile(realpath($key), $key) or die ("ERROR: Could not add file: $key");
  21. }
  22.  
  23. // close and save archive
  24. $zip->close();
  25. echo "Archive created successfully.";
Funciona perfecto.
__________________
Verifica antes de preguntar.
Los verdaderos amigos se hieren con la verdad, para no perderlos con la mentira. - Eugenio Maria de Hostos