【问题标题】:Message: imagecreatefrompng(): SSL operation failed with code 1消息:imagecreatefrompng(): SSL 操作失败,代码为 1
【发布时间】:2016-09-07 07:50:11
【问题描述】:

我收到以下错误:

消息:imagecreatefrompng():SSL 操作失败,代码为 1


消息:imagecreatefrompng():无法启用加密

当我使用 PHP GD 运行此代码时。

function image_test() {
    $im = imagecreatefrompng(base_url()."assets/developed/images/center-poster-bg-transparent.png");
    imagepng($im, APPPATH."../TESTIMAGE.png");
}

谁能帮我解释一下为什么会这样?

【问题讨论】:

  • 我做了很多假设,但是...您可能正在尝试从https URL 打开图像。该 URL 可能正在使用自签名证书。在这种情况下,PHP 中的 OpenSSL 扩展将无法验证证书并失败。

标签: php image codeigniter image-processing php-gd


【解决方案1】:

我猜你使用的是 codeigniter 框架。 我之前也有同样的问题。 而我的解决方案是使用 codeigniter 参数 FCPATH。

您的代码:

function image_test() {
    $im = imagecreatefrompng(base_url()."assets/developed/images/center-poster-bg-transparent.png");
    imagepng($im, APPPATH."../TESTIMAGE.png");
}

必须修改为

function image_test() {
    $im = imagecreatefrompng( FCPATH."assets/developed/images/center-poster-bg-transparent.png" );
    imagepng($im, APPPATH."../TESTIMAGE.png");
}

希望对您有所帮助。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-03-02
    • 2015-04-27
    • 2013-08-25
    • 1970-01-01
    • 2021-05-14
    • 1970-01-01
    • 2015-01-21
    相关资源
    最近更新 更多