-2

こんにちは、smarty で pdf のダウンロード行を作成する必要があります。fpdf から作成したもので、火災のバグで pdf ファイルを表示していますが、smarty でそのためのダウンロード リンクを作成できます。私のコードは以下のとおりです。

$content = $this->view->fetch($pdf->Output());
 $router->disableRender();
    header('Content-Description: File Transfer');
    header('Content-Type: application/pdf');
    header('Content-disposition: attachment; filename="doc.pdf"');
    header('Content-Transfer-Encoding: binary');
    header('Expires: 0');
    header('Cache-Control: must-revalidate');
    header('Pragma: public');

    ob_clean();
    flush();

    readfile(doc.pdf);
    die;

thax advを助けてください......

4

1 に答える 1

0

コードの先頭で、あなたは言っています

$content = $this->view->fetch($pdf->Output());
 $router->disableRender();

それから一番下で、あなたは言います

ob_clean();
flush();

readfile(doc.pdf);
die;

さて、これが PHP の警告 (文字列を仮定した未定義の定数 doc.pdf など) を引き起こすはずであるという事実以外では、このコードはあなたが思っていることを実行しません。PDF の内容をディスクに書き込むことは決してありません。

ファイルを発行する前にファイルに書き込むか$content、単にecho $content.

これをトラブルシューティングしてみましたか?

于 2013-01-07T11:59:42.967 に答える