doushenyu8228 2017-08-16 06:10
浏览 75
已采纳

在codeigniter中使用dompdf而不是在现场制作pdf

I am creating pdfs using this code

$dompdf->loadHtml($html);
$dompdf->setPaper('A4', 'portrait');
$dompdf->render();
$pdf = $dompdf->output();
file_put_contents($this->config->item('file_path') . $pdf_name, $pdf);
$data['pdf'] = site_url('uploads/pdf/' . $pdf_name);

It works perfectly on XMPP localhost, but on LIVE server I get this error.

A PHP Error was encountered
<p>Severity: Warning</p>
<p>Message:  file_put_contents(/home/xyz/public_html/abc/uploads/pdf/quotation_1502863603.pdf): failed to open stream: No such file or directory</p>
<p>Filename: controllers/Admin.php</p>
<p>Line Number: 742</p>

Please guide me what could be the issue on a LIVE server?

  • 写回答

2条回答 默认 最新

  • douqin6785 2017-08-16 07:40
    关注

    Wrong in here $this->config->item('file_path') (path - /home/xyz/public_html/abc/uploads/pdf/). This path belongs to localhost and not to the server.

    You should have try

    $pdf_path = 'uploads/pdf/'.$pdf_name;
    file_put_contents($pdf_path, $pdf);
    

    Codeigniter Environment nothing to do with hosting path, its need an only relative path. As well check permeation on upload path (777)

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 乌班图ip地址配置及远程SSH
  • ¥15 怎么让点阵屏显示静态爱心,用keiluVision5写出让点阵屏显示静态爱心的代码,越快越好
  • ¥15 PSPICE制作一个加法器
  • ¥15 javaweb项目无法正常跳转
  • ¥15 VMBox虚拟机无法访问
  • ¥15 skd显示找不到头文件
  • ¥15 机器视觉中图片中长度与真实长度的关系
  • ¥15 fastreport table 怎么只让每页的最下面和最顶部有横线
  • ¥15 java 的protected权限 ,问题在注释里
  • ¥15 这个是哪里有问题啊?