Es gibt eine Funktion, um Upload-Datei aussehen locken php:
function uploadFileWithCURL($fullFilePath, $targetURL)
{
if (function_exists('curl_file_create')) {
$curlFile = curl_file_create($fullFilePath);
} else {
$curlFile = '@' . realpath($fullFilePath);
}
$post = array('file_contents' => $curlFile);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $targetURL);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
$result = curl_exec($ch);
curl_close($ch);
return $result;
}
Verwendung:
$result = uploadFileWithCURL('path/to/your/fruitbowl.jpg','https://gateway-a.watsonplatform.net/visual-recognition/api/v3/classify?api_key=xxxxa12345&version=2016-05-20');
Was haben Sie bisher versucht? – Jerodev