将 DOMPDF 保存到指定目录,然后作为电子邮件发送

Saving DOMPDF to specified directory and then sending as email

您好,我正在尝试将 dompdf 保存到 codeigniter 文件中的特定目录,然后获取保存的文件并将其作为电子邮件发送。我正在使用 codeigniter 来完成所有这些工作。 这是函数。

public function generateCreditAggreement(){
        $this->load->helper('file'); 
        require_once(APPPATH.'third_party/dompdf/dompdf_config.inc.php');

        $pdfroot  = dirname(dirname(__FILE__));
        $pdfroot .= '/third_party/pdf/';

        $dompdf = new Dompdf();


        $msg = $this->load->view('credit_agreement_view', '', true);
        $html = mb_convert_encoding($msg, 'HTML-ENTITIES', 'UTF-8');
        $dompdf->load_html($html);

        $paper_orientation = 'Potrait'; 
        $dompdf->set_paper($paper_orientation);

            // Render the HTML as PDF
        $dompdf->render();

            // Output the generated PDF to Download folder

//          $dompdf->stream('document.pdf');

            //save the pdf file on the server
            $pdf_string =   $dompdf->output();
            file_put_contents($pdfroot, $pdf_string ); 



    }

我得到的错误是 Message: file_put_contents(C:\Apache24\htdocs\faceloan\faceloan\application/third_party/pdf/): failed to open stream: No such file or directory 但是目录确实存在,而且路径名是正确的。

路径.../third_party/pdf/可能是目录而不是文件。 PHP 无法将您的数据保存为目录。指定文件名作为 file_put_contents() 的第一个参数,例如third_party/pdf/my_document.pdf.