Skip to content

Instantly share code, notes, and snippets.

@caionorder
Last active January 24, 2019 13:28
Show Gist options
  • Save caionorder/3411d51bb78474d2c45ed9f6a829316e to your computer and use it in GitHub Desktop.
Save caionorder/3411d51bb78474d2c45ed9f6a829316e to your computer and use it in GitHub Desktop.
<?php
$avaliacoes = $this->relatoriosM->desempenho_consolidado($_POST);
$zip = new ZipArchive();
$zip->open($_SERVER['DOCUMENT_ROOT'].'/uploads/relatorio.zip', ZipArchive::CREATE);
if($zip->open($_SERVER['DOCUMENT_ROOT'].'/uploads/relatorio.zip')){
foreach ($avaliacoes as $key => $avaliacao) {
$ava = array();
$ava[] = $avaliacao;
$html = (desempenho_consolidado($ava));
$content = $this->export->exportar_relatorio($html, $frase, $_POST['formato']);
$test = $zip->addFile($_SERVER['DOCUMENT_ROOT'].$content,'/file'.$key.'pdf');
}
}
$zip->close();
$archfilename = 'relatorio.zip';
header("Content-type: application/zip");
header("Content-Disposition: attachment; filename = $archfilename");
header("Pragma: no-cache");
header("Expires: 0");
readfile($_SERVER['DOCUMENT_ROOT'].'/uploads/relatorio.zip');
exit;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment