2017-03-03 7 views
1

폴더가 있고 그 폴더 안에 4 개의 파일이 있습니다.이 폴더의 모든 파일을 드롭 박스 폴더에 업로드하고 싶습니다.멀티 플렉스 파일을 폴더에서 드롭 박스 폴더로 업로드하는 방법

어떻게 할 수 있습니까?

다음은 내 코드입니다 :

 $ch = curl_init(); 
    $TOKEN = "token"; 
    $url = 'https://content.dropboxapi.com/2/files/upload'; 
    $cron_log = site_url().'/foldername'; 

    $fp = fopen($cron_log, 'rb'); 
    $size=filesize($cron_log); 

    curl_setopt($ch,CURLOPT_URL,$url); 
    curl_setopt($ch,CURLOPT_POST, 1);    
    curl_setopt($ch,CURLOPT_RETURNTRANSFER, true); 
    $headers = array(); 
    $headers[] = 'Content-Type:application/octet-stream'; 
    $headers[] = 'Dropbox-API-Arg:{"path":"/home/test/address_proof.pdf","mode":{".tag":"add"},"autorename":false,"mute":false}'; 
    $headers[] = "Authorization: Bearer ".$TOKEN; 
    curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); 
    //curl_setopt($ch, CURLOPT_HTTPHEADER, $cheaders); 
    curl_setopt($ch, CURLOPT_PUT, true); 
    curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST'); 
    curl_setopt($ch, CURLOPT_INFILE, $fp); 
    curl_setopt($ch, CURLOPT_INFILESIZE, $size); 
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); 

    $response = curl_exec($ch); 
    $droplist = json_decode($response,true); 

답변

0

/2/파일/통화 당 하나 개의 파일을 업로드 할 수 있습니다 보관 용 API 엔드 포인트를 업로드 할 수 있습니다. 여러 파일을 업로드해야하는 경우 여러 번 호출해야합니다. 4 개의 파일을 업로드하려면 4 번 호출해야합니다. 각각에 대해 관련 Dropbox-API-Arg 값을 지정해야합니다. 예를 들어 파일을 업로드 할 경로를 지정합니다.

+0

감사합니다. 작업하는 중입니다. – Reshma