1 回答
TA贡献1802条经验 获得超6个赞
这段代码对我有用
$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>";
- 1 回答
- 0 关注
- 117 浏览
添加回答
举报