【问题标题】:NotReadableException in AbstractDecoder.php line 80: Unable to init from given url (https://example.net/img/picture.png?1549836294)AbstractDecoder.php 第 80 行中的 NotReadableException:无法从给定的 url 初始化 (https://example.net/img/picture.png?1549836294)
【发布时间】:2019-02-10 22:11:14
【问题描述】:

如何解决这个 laravel 错误?

AbstractDecoder.php 第 80 行中的 NotReadableException:无法初始化 从给定的 url (https://example.net/img/picture.png?1549836294)

这是我的代码: AbstractDecoder.php

    public function initFromUrl($url)
{

    $options = array(
        'http' => array(
            'method'=>"GET",
            'header'=>"Accept-language: en\r\n".
            "User-Agent: Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.2 (KHTML, like Gecko) Chrome/22.0.1216.0 Safari/537.2\r\n"
      )
    );

    $context  = stream_context_create($options);


    if ($data = @file_get_contents($url, false, $context)) {
        return $this->initFromBinary($data);
    }

    throw new \Intervention\Image\Exception\NotReadableException(
        "Unable to init from given url (".$url.")."
    );
}

【问题讨论】:

  • 您需要解释您预期会发生什么,以便该网站的其他用户可以帮助您找到解决方案。

标签: php laravel error-handling


【解决方案1】:

https://example.net/img/picture.png?1549836294 不是图片。

您需要将您复制的示例代码中的 url 替换为 确实返回图像的 url。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2020-04-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多