【问题标题】:mpdf will not open image with allow_url_fopen set to Onmpdf 将不会打开 allow_url_fopen 设置为 On 的图像
【发布时间】:2015-07-25 15:37:06
【问题描述】:

使用 PHP 库 mPDF 我得到错误

找不到图片文件

在 html 中查找 jpg 时。

当 allow_url_fopen 设置为 Off 时不会发生这种情况,但是我需要启用该设置。

【问题讨论】:

  • 它尝试使用 http:// 下载图像,您可以使用 str_replace , strtr 删除 img src 标签(http 链接),但是您是否阅读了手册,也许有跳过下载图像的选项

标签: php mpdf


【解决方案1】:

我设法更改了 mpdf.php 中的检查,它检查 allow_url_fopen 是否为 Off,如果是则不使用 cURL。我将代码从

if ((!$data || !$type) && !ini_get('allow_url_fopen') && function_exists("curl_init")) {
    $this->file_get_contents_by_curl($file, $data);     // needs full url?? even on local (never needed for local)
    if ($data) { $type = $this->_imageTypeFromString($data); }
} 

if ((!$data || !$type) && ini_get('allow_url_fopen') && function_exists("curl_init")) {
    $this->file_get_contents_by_curl($file, $data);     // needs full url?? even on local (never needed for local)
    if ($data) { $type = $this->_imageTypeFromString($data); }
} 

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-02-03
    • 1970-01-01
    • 2013-03-23
    相关资源
    最近更新 更多