<?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 UPLOAD FROM HTTP WITH PHP NOT WORKING in Dropbox API Support &amp; Feedback</title>
    <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/UPLOAD-FROM-HTTP-WITH-PHP-NOT-WORKING/m-p/219063#M11540</link>
    <description>&lt;P&gt;Hello ! I want to upload an image (test.png) from the root of my site to my Dropbox but it doesn't work. My php script is in the same folder than image test.png :&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;PRE&gt;$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, "https://content.dropboxapi.com/2/files/upload");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$post = array(
"file" =&amp;amp;gt; "@" .realpath("test.png")
);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
curl_setopt($ch, CURLOPT_POST, 1);

$headers = array();
$headers[] = "Authorization: Bearer MY_BEAUTIFUL_TOKEN";
$headers[] = "Dropbox-Api-Arg: {\"path\": \"/test.png\",\"mode\": \"add\",\"autorename\": true,\"mute\": false}";
$headers[] = "Content-Type: application/octet-stream";
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);

$curl_response_res = curl_exec ($ch);

echo $curl_response_res; // Server response
print_r(curl_getinfo($ch)); // Http Response
curl_close($ch);

fclose($fh_res);&lt;/PRE&gt;
&lt;P&gt;&lt;BR /&gt;What is the problem ?&lt;/P&gt;</description>
    <pubDate>Wed, 29 May 2019 09:23:04 GMT</pubDate>
    <dc:creator>Aziros</dc:creator>
    <dc:date>2019-05-29T09:23:04Z</dc:date>
    <item>
      <title>UPLOAD FROM HTTP WITH PHP NOT WORKING</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/UPLOAD-FROM-HTTP-WITH-PHP-NOT-WORKING/m-p/219063#M11540</link>
      <description>&lt;P&gt;Hello ! I want to upload an image (test.png) from the root of my site to my Dropbox but it doesn't work. My php script is in the same folder than image test.png :&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;PRE&gt;$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, "https://content.dropboxapi.com/2/files/upload");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$post = array(
"file" =&amp;amp;gt; "@" .realpath("test.png")
);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
curl_setopt($ch, CURLOPT_POST, 1);

$headers = array();
$headers[] = "Authorization: Bearer MY_BEAUTIFUL_TOKEN";
$headers[] = "Dropbox-Api-Arg: {\"path\": \"/test.png\",\"mode\": \"add\",\"autorename\": true,\"mute\": false}";
$headers[] = "Content-Type: application/octet-stream";
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);

$curl_response_res = curl_exec ($ch);

echo $curl_response_res; // Server response
print_r(curl_getinfo($ch)); // Http Response
curl_close($ch);

fclose($fh_res);&lt;/PRE&gt;
&lt;P&gt;&lt;BR /&gt;What is the problem ?&lt;/P&gt;</description>
      <pubDate>Wed, 29 May 2019 09:23:04 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/UPLOAD-FROM-HTTP-WITH-PHP-NOT-WORKING/m-p/219063#M11540</guid>
      <dc:creator>Aziros</dc:creator>
      <dc:date>2019-05-29T09:23:04Z</dc:date>
    </item>
    <item>
      <title>Re: UPLOAD FROM HTTP WITH PHP NOT WORKING</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/UPLOAD-FROM-HTTP-WITH-PHP-NOT-WORKING/m-p/219225#M11552</link>
      <description>What output are you getting? The HTTP response body from the API should contain either the metadata for the uploaded file, or an error indicating why the upload failed.</description>
      <pubDate>Wed, 03 May 2017 17:58:31 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/UPLOAD-FROM-HTTP-WITH-PHP-NOT-WORKING/m-p/219225#M11552</guid>
      <dc:creator>Greg-DB</dc:creator>
      <dc:date>2017-05-03T17:58:31Z</dc:date>
    </item>
    <item>
      <title>Re: UPLOAD FROM HTTP WITH PHP NOT WORKING</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/UPLOAD-FROM-HTTP-WITH-PHP-NOT-WORKING/m-p/219244#M11561</link>
      <description>&lt;P&gt;Hello ! Thanks for interest, I found a solution on Stack Overflow :&lt;/P&gt;
&lt;PRE&gt;$path = 'test.png';
		$fp = fopen($path, 'rb');
		$size = filesize($path);

		$cheaders = array('Authorization: Bearer &amp;lt;TOKEN&amp;gt;',
						  'Content-Type: application/octet-stream',
						  'Dropbox-API-Arg: {"path":"/'.$path.'", "mode":"add"}');

		$ch = curl_init('https://content.dropboxapi.com/2/files/upload');
		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);

		echo $response;
		curl_close($ch);
		fclose($fp);&lt;/PRE&gt;
&lt;P&gt;&lt;A href="https://stackoverflow.com/documentation/dropbox-api/409/uploading-a-file/1354/uploading-a-file-via-curl-in-php#t=201612231606567112687" target="_self"&gt;https://stackoverflow.com/documentation/dropbox-api/409/uploading-a-file/1354/uploading-a-file-via-curl-in-php#t=201612231606567112687&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 03 May 2017 20:15:35 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/UPLOAD-FROM-HTTP-WITH-PHP-NOT-WORKING/m-p/219244#M11561</guid>
      <dc:creator>Aziros</dc:creator>
      <dc:date>2017-05-03T20:15:35Z</dc:date>
    </item>
  </channel>
</rss>

