gpt4 book ai didi

php - 287 不是有效的 cURL 句柄资源

转载 作者:可可西里 更新时间:2023-10-31 23:48:09 24 4
gpt4 key购买 nike

最近使用 PHP5-FPM 将服务器从 Apache2 切换到 nginx/1.4.6,每次我尝试运行 curl 我得到:

curl_error(): 287 is not a valid cURL handle resource

安装了 Curl(在 CLI 中运行“curl url”可以正常工作),还安装了 PHP 模块。

我的代码:

$file_name_with_full_path = $composed_filename;
$post = array('image'=>'@'.$file_name_with_full_path);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "url");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt ($ch, CURLOPT_PORT , 443);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_SSLVERSION, 3);
curl_setopt($ch, CURLOPT_TIMEOUT, 300);
$result = curl_exec ($ch);
curl_close ($ch);

我四处搜索并找到了几个答案,但没有一个有效。发现一个说 cURL 可能在它完成之前删除了句柄,我该如何测试它?

最佳答案

我认为你应该使用 curl_file_create功能。试试这个

$file = curl_file_create('fullpath/to/image.jpg','image/jpeg','the_image');
$data = array('the_image' => $file);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);

关于php - 287 不是有效的 cURL 句柄资源,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22644543/

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