0

我想通过这个循环下载我的数据库中包含的所有 pdf。当我单击按钮时,仅下载第一个文件。

<?php
include_once('functions/functions.php');
require_once('../invoice/html2pdf.class.php');
if (isset($_GET['download'])) {
    if ($_GET['download'] == 'all') {
        $req = sql_query("SELECT * FROM invoice");
        $content = ''; 
        while ($res = mysqli_fetch_assoc($req)) {

            $html2pdf = new HTML2PDF('P', 'A4', 'fr');
            $html2pdf->setDefaultFont('Arial');
            $content = $res['content']; 
            $html2pdf->writeHTML($content);
            ob_end_clean();
            $html2pdf->Output('' . $res['date'] . '-' . $res['user'] . '.pdf', 'D');
        }
    }
}
?>
<panel class="panel panel-flat">
    <a href="invoice?download=all">Télécharger toutes les factures</a>
</panel>
4

1 回答 1

1

每次下载只能提供 1 个文件。

您当然可以将它们全部添加到 zip 存档中,并提供下载。

于 2015-12-28T10:48:40.390 回答