How do I save a PDF to my root file? DOMPDF

坚强是说给别人听的谎言 提交于 2019-12-23 04:43:35

问题


I am using a free extension of opencart which allows me to download invoice in PDF to my local system (Downloads folder).

I want two things to happen

  1. I want to download PDF file in my root. (if I am working on localhost I want the file to download in root\abc\ )

  2. The other thing i want is that there is an email textbox and email button what I want is that I want to send email to user(eAddress written in textbox) with auto attachment of that downloaded pdf file located in(root\abc)

CODE :

$pdf = (isset($this->request->get['pdf'])) ? true : false;
$eFlag= (isset($this->request->get['email'])) ? true : false;

if ($pdf){
$this->response->setOutput(pdf($this->render(),$this->data['orders']));
}
elseif ($eFlag) {
$fp = fopen(DIR_DOWNLOAD . "meeru.pdf","wb");
$dataHtml = $this->render();
$name = $this->data['orders'];
if (count($name) > 1) {
$name = "Orders";
}else{
$name = 'Order_'.$name[0]['order_id'];
}
$pdf = new DOMPDF;
$pdf->load_html($dataHtml );
$pdf->render();
fwrite($fp , $pdf->output( array("compress" => 0) ));
fclose($fp );
$this->response->setOutput("File Saved");
}
else{
$this->response->setOutput($this->render());
}

Its downloading just one time (for the first time in root/download)

来源:https://stackoverflow.com/questions/30235251/how-do-i-save-a-pdf-to-my-root-file-dompdf

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!