gpt4 book ai didi

php - 在 PHP imagepng 中禁用 SSL

转载 作者:太空宇宙 更新时间:2023-11-03 14:08:01 26 4
gpt4 key购买 nike

当我尝试在 PHP 中调用 imagepng 时出现 SSL 错误。

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

我知道有一种方法可以在使用 get_put_contents() 时禁用 SSL 验证,但是您可以使用 imagepng 来实现吗?谢谢。

最佳答案

不是直接的,但是你应该能够将 file_get_contentsimagecreatefromstring 结合起来,例如

$context = [
'ssl' => [
'verify_peer' => false,
'verify_peer_name' => false,
],
];

$url = 'https://www.google.co.uk/images/nav_logo242.png';
$response = file_get_contents($url, false, stream_context_create($context));

$img = imagecreatefromstring($response);

关于php - 在 PHP imagepng 中禁用 SSL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37257638/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com