Hello! I have an error when using CURL in PHP, I do not have a return of the ID of the study created in Orthanc. When I try CURL in the command prompt (CMD), it does return a value on the screen. This is the PHP code that performs this function, can you help me where the error is: $cliente = curl_init();
$fileAttachment = new CURLFile(realpath(‘estudios/1001.zip’),‘file/zip’,‘1001.zip’);
$fields = array(
‘files’ => $fileAttachment
);
curl_setopt($cliente, CURLOPT_URL, “http://192.168.10.106/instances/”);
curl_setopt($cliente, CURLOPT_POST, 1);
curl_setopt($cliente, CURLOPT_USERPWD, ‘usuario:clave’);
curl_setopt($cliente, CURLOPT_POSTFIELDS, $fields);
curl_setopt($cliente, CURLOPT_RETURNTRANSFER, true);
curl_setopt($cliente, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
$response = curl_exec($cliente);
$errors = curl_error($cliente);
$resultStatus = curl_getinfo($cliente);
curl_close($cliente);
if($resultStatus[‘http_code’] == 200) {
$respuesta=array(“id” => 1, ‘mensaje’=>‘debe llegar’, ‘datos’=>json_decode($response), ‘datos2’=>json_decode($response,1), ‘datos3’=>$response, ‘datos4’=>json_decode($response,1), ‘error’=>json_decode($errors,1));
} else {
$respuesta=array(“id” => 0, ‘mensaje’=>‘No hay Conexión con el Servidor PACS’,‘respuesta’=>$resultStatus, ‘error’=>json_decode($errors,1));
}
echo json_encode($respuesta);
Hello,
You must not use “array()” in “CURLOPT_POSTFIELDS”. The binary file must be provided as it. Here is a full sample:
https://stackoverflow.com/q/63473936
(Disclaimer: untested, as this is a pure PHP question that is not specific to Orthanc).
Sébastien-