Uploading a file to Nextcloud with php curl in postman but the file uploaded is empty Uploading a file to Nextcloud with php curl in postman but the file uploaded is empty curl curl

Uploading a file to Nextcloud with php curl in postman but the file uploaded is empty


This code work for me

$nombre_fichero = "C:\\pruebas\\Documento_1.pdf";$gestor = fopen($nombre_fichero, "rb");$contenido = fread($gestor, filesize($nombre_fichero));fclose($gestor);    $login = 'usuario';$password = 'clave';$url = 'https://dominio.com/remote.php/dav/files/usuario/folder1/D4.pdf';$options = array(CURLOPT_SAFE_UPLOAD => true,CURLOPT_HEADER => true,CURLOPT_CUSTOMREQUEST => "PUT",CURLOPT_URL => $url,CURLOPT_POSTFIELDS => $contenido,CURLOPT_SSL_VERIFYPEER=> false,CURLOPT_RETURNTRANSFER=> 1,CURLOPT_HTTPAUTH=>CURLAUTH_BASIC,CURLOPT_USERPWD=> $login.':'.$password,CURLOPT_HTTPHEADER=>array('OCS-APIRequest: true'));$curl = curl_init();curl_setopt_array($curl, $options);$response = curl_exec($curl);curl_close($curl);echo "<pre>";echo $response;echo "</pre>";