Php 将DOMPDF保存到指定目录,然后作为电子邮件发送
您好,我正在尝试将dompdf保存到codeigniter文件中的特定目录,然后将保存的文件作为电子邮件发送。我正在使用codeigniter来完成所有这些工作。 下面是函数Php 将DOMPDF保存到指定目录,然后作为电子邮件发送,php,codeigniter,dompdf,Php,Codeigniter,Dompdf,您好,我正在尝试将dompdf保存到codeigniter文件中的特定目录,然后将保存的文件作为电子邮件发送。我正在使用codeigniter来完成所有这些工作。 下面是函数 public function generateCreditAggreement(){ $this->load->helper('file'); require_once(APPPATH.'third_party/dompdf/dompdf_config.inc.php');
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 );
}
我得到的错误是
消息:文件内容(C:\Apache24\htdocs\faceloan\faceloan\application/third\u party/pdf/):无法打开流:没有这样的文件或目录
但是目录确实存在,路径名是正确的。路径
../third\u party/pdf/
可能是一个目录而不是一个文件。PHP无法将数据保存为目录。指定文件名作为file\u put\u contents()
的第一个参数,例如third\u/pdf/my\u document.pdf
路径../third\u/pdf/
可能是一个目录而不是文件。PHP无法将数据保存为目录。指定文件名作为文件内容()的第一个参数,例如第三方/pdf/my\u document.pdf