<?php
$DIRETORIO = ‘arquivo/donwload’;
$NOMEZIP = ‘teste’;
$NOMEFILES= array(‘teste1.csv’,’teste2.xls’,’teste3.jpg’);
$zip = new ZipArchive;
$res = $zip->open($DIRETORIO.’/’.$NOMEZIP.’.zip’, ZipArchive::CREATE);
foreach($NOMEFILES as $nome_file){
#antes da virgula é o local, e depois é o nome que quer dar para o arquivo
$zip->addFile($DIRETORIO.’/’.$nome_file,$nome_file);
}
$zip->close();
header(“Content-type: application/zip”);
header(“Content-Disposition: attachment; filename=”.$NOMEZIP .”.zip”);
header(“Content-length: ” . filesize($diretorio.’/’.$NOMEZIP .’.zip’));
header(“Pragma: no-cache”);
header(“Expires: 0″);
readfile($diretorio.”/”.$NOMEZIP .”.zip”);
?>