/ Published in: PHP

Lo dicho, una clase en PHP que agrega archivos a un zip y forza su descarga, para este caso los archivos que agrega son XML.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
<?php /* * To change this template, choose Tools | Templates * and open the template in the editor. */ /** * Clase usada para comprimir los xml dentro de un zip * el archivo se llama ArchivoZip.inc.php * @author Cesar Nava Camacho */ class ArchivoZip{ var $zip; var $nombreArchivo; function ArchivoZip(){ //Se crea un archivo temporal en la carpeta temporal default del sistema servidor $this->zip = new ZipArchive(); $this->zip->open($this->nombreArchivo, ZipArchive::OVERWRITE); $this->zip->addEmptyDir("xmlRedalyc"); } function agregarArchivo($archivo, $nombre){ $this->zip->addFromString("xmlRedalyc/ $nombre.xml", $archivo); } function cerrarZip(){ $this->zip->close(); } } ?>
Comments
