【问题标题】:file_exists(): open_basedir restriction in effect. File(/tmp/log.htm) is not within the allowed path(s)file_exists():open_basedir 限制生效。文件(/tmp/log.htm)不在允许的路径中
【发布时间】:2019-08-07 05:43:38
【问题描述】:

我正在构建使用 CodeIgniter 和 DOMPDF 生成应用程序的 pdf。它在我的本地主机中工作正常,但是当我将这些文件移动到服务器时,它给了我以下错误。请问,我该如何解决这个问题?

Severity: Warning

Message: file_exists(): open_basedir restriction in effect. File(/tmp/log.htm) is not within the allowed path(s): (/home/admin/web/fryapps.com/public_html:/home/admin/tmp)

Filename: src/Dompdf.php

Line Number: 714

Backtrace:

File: /home/admin/web/fryapps.com/public_html/application/libraries/dompdf/src/Dompdf.php
Line: 714
Function: file_exists

File: /home/admin/web/fryapps.com/public_html/application/controllers/Createpdf.php
Line: 31
Function: render

图片错误路径:https://imgur.com/a/zQo1873

这是我的代码:

$htmlcontent= $this->load->view('admin/test',$data,true);              
$this->pdf->loadHtml($htmlcontent);
$this->pdf->render();
$this->pdf->stream("report.pdf",array("Attachment=>0"));

任何人,请帮我解决这个问题?

【问题讨论】:

  • 提供绝对路径/home/admin/tmp/
  • @kuh-chan 我必须在哪里编辑这个?
  • 如何解决这个问题?
  • 当您查看 Dompdf 的代码时,您会发现它会创建一个 logOutputFile。您可以在选项数组中设置它
  • 更多 $this->pdf->set_option('logOutputFile', $this->getTempDir() . DIRECTORY_SEPARATOR . 'log.htm'); 等等...我为什么要为你阅读文档?

标签: php codeigniter dompdf


【解决方案1】:

创建文件夹“/home/admin/web/example.com/tmp”

使用它

$this->pdf->set_options('tempDir','/home/admin/web/example.com/tmp');

类使用sys_get_temp_dir();

在 VirtualHost 中为 example.com 设置它

php_admin_value sys_temp_dir "/home/admin/web/example.com/tmp"

【讨论】:

【解决方案2】:

我已经通过升级 php 版本的 cpanel 解决了这个问题。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2020-12-21
    • 1970-01-01
    • 2010-12-23
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多