Need to see if your shared folder is taking up space on your dropbox 👨💻? Find out how to check here.
Forum Discussion
Informatica P.
10 years agoNew member | Level 1
Is posible upload file whit PHP and get public share link to file?
Hello,
I want upload a file whit API PHP. But i want get the public link share to my users download the file from their home.
Is posible?
David D.86
10 years agoNew member | Level 1
This is the code I have for PHP v2 for uploading a file, using curl functions, but I'm at a loss as to how to describe what the POST data should look like.
<?php
$ch = curl_init();
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
$token = "yourtoken";
$host = "https://api.dropboxapi.com/";
//set headers
$headers = array('Authorization: Bearer '.$token,
'Content-Type: application/octet-stream',
'Dropbox-API-Arg: {"path":"/test.txt","mode":"add"}',
);
$f = fopen("test.txt", "rb");
curl_setopt($ch, CURLOPT_URL, $host);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
// What should the POST data look like? Using the file handle? That doesn't work.
curl_setopt($ch, CURLOPT_POSTFIELDS, $f);
$response = curl_exec($ch);
fclose($f);
echo "<br />File Upload Response: <br />";
var_export($response);
echo "<br />File UPload HTTP CODE: <br />";
var_export(curl_getinfo($ch, CURLINFO_HTTP_CODE));
curl_close($ch);
About Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.
The Dropbox Community team is active from Monday to Friday. We try to respond to you as soon as we can, usually within 2 hours.
If you need more help you can view your support options (expected response time for an email or ticket is 24 hours), or contact us on X, Facebook or Instagram.
For more info on available support options for your Dropbox plan, see this article.
If you found the answer to your question in this Community thread, please 'like' the post to say thanks and to let us know it was useful!