Open kevinvennitti opened 1 year ago
Hi there!
I am trying to send multiple images to PlantNet API in PHP, and thanks to the doc, everything is fine with one image from an HTML input file:
$data = array( 'organs' => 'flower', 'images' => makeCurlFile($_FILES['images']['tmp_name'][0]) ); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_POSTFIELDS, $data); $response = curl_exec($ch); curl_close($ch);
But I can't find the right way to send multiple files:
Array to string conversion
// This does not work $data = array( 'organs' => [ 'flower', 'flower' ], 'images' => [ makeCurlFile($_FILES['images']['tmp_name'][0]), makeCurlFile($_FILES['images']['tmp_name'][1]) ] );
// This does not work $data = array( 'organ_1' => 'flower', 'organ_2' => 'flower', 'image_1' => makeCurlFile($_FILES['images']['tmp_name'][0]), 'image_2' => makeCurlFile($_FILES['images']['tmp_name'][1]) );
What did I missed? 🙂
Hi,
For such a case we recommend using Guzzle library, as in this example : https://github.com/plantnet/my.plantnet/blob/master/examples/post/php/run.php
Hi there!
I am trying to send multiple images to PlantNet API in PHP, and thanks to the doc, everything is fine with one image from an HTML input file:
But I can't find the right way to send multiple files:
Array to string conversion
error in CURLOPT_POSTFIELDS)What did I missed? 🙂