首页 > 解决方案 > 在 owncloud 中使用 CURL 恢复上传

问题描述

我正在使用 curl 请求将文件上传到 owncloud。如果连接中断如何恢复上传?因为我必须上传大文件。下面是我的代码

    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, 'http://server/owncloud/remote.php/webdav/' . basename($filename));
    curl_setopt($ch, CURLOPT_NOPROGRESS, false );
    curl_setopt($ch, CURLOPT_FAILONERROR, true); 
    curl_setopt($ch, CURLOPT_USERPWD, "user:password");
    curl_setopt($ch, CURLOPT_PUT, 1);

    $fh_res = fopen($file_path_str, 'r');

    curl_setopt($ch, CURLOPT_INFILE, $fh_res);
    curl_setopt($ch, CURLOPT_INFILESIZE, filesize($file_path_str));


    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_BINARYTRANSFER, TRUE); // --data-binary
    $curl_response_res = curl_exec ($ch);

如果连接中断,如何继续上传?

标签: phpcurlowncloud

解决方案


推荐阅读