【发布时间】:2014-05-03 21:12:57
【问题描述】:
最近使用 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 的
@filenameAPI。您应该使用CURLFile 类。 -
如何打印 curl 错误?可能是在关闭 curl 句柄之后?