287 is not a valid cURL processing resource

A newly connected server from Apache2 to nginx / 1.4.6 with PHP5-FPM and every time I try to start curl I get:

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

Curl is installed (the "curl url" works in the CLI; it works fine), the PHP module is also installed.

My code is:

$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);

I searched and found some answers, but none of them worked. Found one that said cURL may have deleted the handle before it was completed, how can I check this?

+4
source share
1 answer

I think you should use the curl_file_create function . try it

$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);
0
source

Source: https://habr.com/ru/post/1533401/


All Articles