这是我的批量
function bulk() {
$action = $this->input->post('action');
if ($action == "export") {
$export = $this->input->post('msg');
for ($i=0; $i < count($export) ; $i++) {
$this->load->library('Pdfgenerator');
$users = $this->model_csv->getDatabyDescription($export[$i]);
$desc = $users['description'];
$name = substr((strrchr($desc, '-')), 2);
$html = $this->load->view('formulir_new2', $users, true);
$this->pdfgenerator->generate($html,"E-Tax" . time() . $name, $i);
}
// echo "<script type='text/javascript'>";
// for($i=0;$i< count($export); $i++){
// $users = $this->model_csv->getDatabyDescription($export[$i]);
// $desc = $users['description'];
// $name = substr((strrchr($desc, '-')), 2);
// // echo "window.open('/pdf/E-tax{time()}{$name}{$i}.pdf');" ;
// echo "window.open('/pdf/E-Tax" . time() . $name . $i . ".pdf";
// }
// echo "</script>";
}
这是我的pdf生成器库
public function generate($html, $filename, $i){
if($i == 0)
{
define('DOMPDF_ENABLE_AUTOLOAD', false);
}
require_once("./vendor/dompdf/dompdf/autoload.inc.php");
$file_to_save = $_SERVER['DOCUMENT_ROOT'] . '/exportdata/uploads/pdf/';
$dompdf = new dompdf();
$options = new Options();
$options->setIsRemoteEnabled(true);
$dompdf->setOptions($options);
$dompdf->set_paper(array(0,0, 612, 936), 'portrait');
$dompdf->load_html($html);
$dompdf->render();
$abc = $dompdf->output();
file_put_contents($ file_to_save。$ filename。$ i。“。pdf”,$ abc);}
答案 0 :(得分:0)
您可以使用ZipArchive
$zip = new ZipArchive ();
$zipfile = "myArchive.zip";
$zip->open ( $zipfile, ZipArchive::OVERWRITE );
for($i = 0; $i < count ( $document ); $i ++) {
$fileinfo = pathinfo ( $document [$i] );
if (file_exists ( $document [$i] )) {
$zip->addFile ( $document [$i], "myFolder/" . $fileinfo ['filename'] . "." . $fileinfo ['extension'] );
}
}
$zip->close ();