<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic uploadToDropbox cURL Root in Dropbox API Support &amp; Feedback</title>
    <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/uploadToDropbox-cURL-Root/m-p/606323#M28118</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I was trying cURL, but I am pretty bad at it.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I would need your assistance.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;function uploadToDropbox($path, $folder="\0", $name="") {&lt;/P&gt;
&lt;P&gt;$url = "&lt;A href="https://api.dropbox.com/oauth2/token" target="_blank" rel="noopener"&gt;https://api.dropbox.com/oauth2/token&lt;/A&gt;";&lt;/P&gt;
&lt;P&gt;$curl = curl_init($url);&lt;BR /&gt;curl_setopt($curl, CURLOPT_URL, $url);&lt;BR /&gt;curl_setopt($curl, CURLOPT_POST, true);&lt;BR /&gt;curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);&lt;BR /&gt;curl_setopt($curl, CURLOPT_USERPWD, "xxx");&lt;/P&gt;
&lt;P&gt;$headers = array(&lt;BR /&gt;"Content-Type: application/x-www-form-urlencoded",&lt;BR /&gt;"Authorization: Basic xx",&lt;BR /&gt;);&lt;BR /&gt;curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);&lt;/P&gt;
&lt;P&gt;$data = "grant_type=refresh_token&amp;amp;refresh_token=xx";&lt;/P&gt;
&lt;P&gt;curl_setopt($curl, CURLOPT_POSTFIELDS, $data);&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;$resp = curl_exec($curl);&lt;BR /&gt;curl_close($curl);&lt;BR /&gt;$outCurl = json_decode($resp,True);&lt;BR /&gt;$token = $outCurl["access_token"];&lt;/P&gt;
&lt;P&gt;$dropboxFp = fopen($path, 'rb');&lt;BR /&gt;$dropboxSize = filesize($path);&lt;BR /&gt;$dropboxCheaders = array('Authorization: Bearer '.$token,&lt;BR /&gt;'Content-Type: application/octet-stream',&lt;BR /&gt;'Dropbox-API-Path-Root: {".tag": "namespace_id", "namespace_id": "7"}',&lt;BR /&gt;'Dropbox-API-Arg: {"path":"/Outside of Me Folder/Folder/Folder2/Folder3/Folder4/'.$_SESSION['company_name'].'/'.$_SESSION['product_name'].'/'.$folder.$name.'", "mode":"add"}');&lt;/P&gt;
&lt;P&gt;$dropboxCh = curl_init('&lt;A href="https://content.dropboxapi.com/2/files/upload" target="_blank" rel="noopener"&gt;https://content.dropboxapi.com/2/files/upload&lt;/A&gt;');&lt;BR /&gt;curl_setopt($dropboxCh, CURLOPT_HTTPHEADER, $dropboxCheaders);&lt;BR /&gt;curl_setopt($dropboxCh, CURLOPT_PUT, true);&lt;BR /&gt;curl_setopt($dropboxCh, CURLOPT_CUSTOMREQUEST, 'POST');&lt;BR /&gt;curl_setopt($dropboxCh, CURLOPT_INFILE, $dropboxFp);&lt;BR /&gt;curl_setopt($dropboxCh, CURLOPT_INFILESIZE, $dropboxSize);&lt;BR /&gt;curl_setopt($dropboxCh, CURLOPT_RETURNTRANSFER, true);&lt;BR /&gt;$dropboxResponse = curl_exec($dropboxCh);&lt;/P&gt;
&lt;P&gt;echo $dropboxResponse;&lt;BR /&gt;curl_close($dropboxCh);&lt;BR /&gt;fclose($dropboxFp);&lt;BR /&gt;}&lt;/P&gt;
&lt;P&gt;$prodreport = "Reports/";&lt;BR /&gt;$prodimgs = "Product Images/";&lt;BR /&gt;$prodothrs = "Others/";&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It put things in this folder:&lt;/P&gt;
&lt;P&gt;Me &amp;gt; Folder &amp;gt; Folder2 &amp;gt; Folder3 &amp;gt; Folder4 &amp;gt; Folder5 &amp;gt; test&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It should put things here:&lt;/P&gt;
&lt;P&gt;Outside of Me Folder &amp;gt; Folder &amp;gt; Folder2 &amp;gt; Folder3 &amp;gt; Folder4 &amp;gt; Folder5 &amp;gt; test&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you!&lt;/P&gt;</description>
    <pubDate>Thu, 30 Jun 2022 17:17:54 GMT</pubDate>
    <dc:creator>MeloX</dc:creator>
    <dc:date>2022-06-30T17:17:54Z</dc:date>
    <item>
      <title>uploadToDropbox cURL Root</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/uploadToDropbox-cURL-Root/m-p/606323#M28118</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I was trying cURL, but I am pretty bad at it.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I would need your assistance.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;function uploadToDropbox($path, $folder="\0", $name="") {&lt;/P&gt;
&lt;P&gt;$url = "&lt;A href="https://api.dropbox.com/oauth2/token" target="_blank" rel="noopener"&gt;https://api.dropbox.com/oauth2/token&lt;/A&gt;";&lt;/P&gt;
&lt;P&gt;$curl = curl_init($url);&lt;BR /&gt;curl_setopt($curl, CURLOPT_URL, $url);&lt;BR /&gt;curl_setopt($curl, CURLOPT_POST, true);&lt;BR /&gt;curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);&lt;BR /&gt;curl_setopt($curl, CURLOPT_USERPWD, "xxx");&lt;/P&gt;
&lt;P&gt;$headers = array(&lt;BR /&gt;"Content-Type: application/x-www-form-urlencoded",&lt;BR /&gt;"Authorization: Basic xx",&lt;BR /&gt;);&lt;BR /&gt;curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);&lt;/P&gt;
&lt;P&gt;$data = "grant_type=refresh_token&amp;amp;refresh_token=xx";&lt;/P&gt;
&lt;P&gt;curl_setopt($curl, CURLOPT_POSTFIELDS, $data);&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;$resp = curl_exec($curl);&lt;BR /&gt;curl_close($curl);&lt;BR /&gt;$outCurl = json_decode($resp,True);&lt;BR /&gt;$token = $outCurl["access_token"];&lt;/P&gt;
&lt;P&gt;$dropboxFp = fopen($path, 'rb');&lt;BR /&gt;$dropboxSize = filesize($path);&lt;BR /&gt;$dropboxCheaders = array('Authorization: Bearer '.$token,&lt;BR /&gt;'Content-Type: application/octet-stream',&lt;BR /&gt;'Dropbox-API-Path-Root: {".tag": "namespace_id", "namespace_id": "7"}',&lt;BR /&gt;'Dropbox-API-Arg: {"path":"/Outside of Me Folder/Folder/Folder2/Folder3/Folder4/'.$_SESSION['company_name'].'/'.$_SESSION['product_name'].'/'.$folder.$name.'", "mode":"add"}');&lt;/P&gt;
&lt;P&gt;$dropboxCh = curl_init('&lt;A href="https://content.dropboxapi.com/2/files/upload" target="_blank" rel="noopener"&gt;https://content.dropboxapi.com/2/files/upload&lt;/A&gt;');&lt;BR /&gt;curl_setopt($dropboxCh, CURLOPT_HTTPHEADER, $dropboxCheaders);&lt;BR /&gt;curl_setopt($dropboxCh, CURLOPT_PUT, true);&lt;BR /&gt;curl_setopt($dropboxCh, CURLOPT_CUSTOMREQUEST, 'POST');&lt;BR /&gt;curl_setopt($dropboxCh, CURLOPT_INFILE, $dropboxFp);&lt;BR /&gt;curl_setopt($dropboxCh, CURLOPT_INFILESIZE, $dropboxSize);&lt;BR /&gt;curl_setopt($dropboxCh, CURLOPT_RETURNTRANSFER, true);&lt;BR /&gt;$dropboxResponse = curl_exec($dropboxCh);&lt;/P&gt;
&lt;P&gt;echo $dropboxResponse;&lt;BR /&gt;curl_close($dropboxCh);&lt;BR /&gt;fclose($dropboxFp);&lt;BR /&gt;}&lt;/P&gt;
&lt;P&gt;$prodreport = "Reports/";&lt;BR /&gt;$prodimgs = "Product Images/";&lt;BR /&gt;$prodothrs = "Others/";&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It put things in this folder:&lt;/P&gt;
&lt;P&gt;Me &amp;gt; Folder &amp;gt; Folder2 &amp;gt; Folder3 &amp;gt; Folder4 &amp;gt; Folder5 &amp;gt; test&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It should put things here:&lt;/P&gt;
&lt;P&gt;Outside of Me Folder &amp;gt; Folder &amp;gt; Folder2 &amp;gt; Folder3 &amp;gt; Folder4 &amp;gt; Folder5 &amp;gt; test&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you!&lt;/P&gt;</description>
      <pubDate>Thu, 30 Jun 2022 17:17:54 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/uploadToDropbox-cURL-Root/m-p/606323#M28118</guid>
      <dc:creator>MeloX</dc:creator>
      <dc:date>2022-06-30T17:17:54Z</dc:date>
    </item>
    <item>
      <title>Re: uploadToDropbox cURL Root</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/uploadToDropbox-cURL-Root/m-p/606461#M28122</link>
      <description>&lt;P&gt;By default, API calls operate in the "member folder" of the connected account, not the "team space". That is why you would get files uploaded to your own member folder by default. From your description, you want to upload them to the team space instead.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can configure API calls to operate in the "&lt;A href="https://help.dropbox.com/teams-admins/team-member/team-space-overview" rel="noopener noreferrer" target="_blank"&gt;team space&lt;/A&gt;" instead. To do so, you'll need to set the "Dropbox-Api-Path-Root" header. In the code you shared here, I see you do have the "Dropbox-Api-Path-Root" header, but you're setting a "namespace_id" of "7". The "7" is just an example from the guide/documentation. For your actual code, you will need to set your own value. Refer to &lt;A href="https://developers.dropbox.com/dbx-team-files-guide" rel="noopener noreferrer" target="_blank"&gt;the Team Files Guide&lt;/A&gt; and &lt;A href="https://www.dropbox.com/developers/reference/path-root-header-modes" target="_blank"&gt;Path Root Header Modes documentation&lt;/A&gt; for information on how to retrieve and use the correct value for the connected account.&lt;/P&gt;</description>
      <pubDate>Wed, 29 Jun 2022 16:21:54 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/uploadToDropbox-cURL-Root/m-p/606461#M28122</guid>
      <dc:creator>Greg-DB</dc:creator>
      <dc:date>2022-06-29T16:21:54Z</dc:date>
    </item>
    <item>
      <title>Re: uploadToDropbox cURL Root</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/uploadToDropbox-cURL-Root/m-p/606618#M28125</link>
      <description>&lt;P&gt;Thank you so much, Greg!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I got it to work!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I appreciate your help.&lt;/P&gt;</description>
      <pubDate>Thu, 30 Jun 2022 06:26:06 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/uploadToDropbox-cURL-Root/m-p/606618#M28125</guid>
      <dc:creator>MeloX</dc:creator>
      <dc:date>2022-06-30T06:26:06Z</dc:date>
    </item>
  </channel>
</rss>

