Your workflow is unique 👨💻 - tell us how you use Dropbox here.
Forum Discussion
Burak_Cayir
8 years agoExplorer | Level 3
I can't download my files with PHP Core API
I have a Dropbox basic account, and these are my download codes. But I cant download my files with core API. Please help me .
require_once "lib/Dropbox/autoload.php";
use \Dropbox as dbx;
$appInfo ...
Burak_Cayir
8 years agoExplorer | Level 3
What is the difference between new and old access tokens ? Why I should take a new one ? Old token perfectly uploaded my files but didnt download any file . I should try new access token ? Please let me know can all users upload files and download files with my Dropbox basic account ? I respect your business but I am going to crazy . I think I will delete my dropbox account :(
Greg-DB
Dropbox Community Moderator
8 years agoBy new access token, I mean you should retrieve another. This won't be any different that the old one, except that the old one is now revoked.
It is important that the old one was revoked because you posted it publicly, meaning any person could have taken it and accessed your account.
Once you have a working access token again, let us know the error message you get when you try to download a file. (Just don't post the new access token itself.)
It is important that the old one was revoked because you posted it publicly, meaning any person could have taken it and accessed your account.
Once you have a working access token again, let us know the error message you get when you try to download a file. (Just don't post the new access token itself.)
- Burak_Cayir8 years agoExplorer | Level 3
Ok , I got a new token and I can use it. I can upload any file or I can list my dropbox files. But I cant download my files. I am adding codes again without access token.
require_once "lib/Dropbox/autoload.php"; use \Dropbox as dbx; $appInfo = dbx\AppInfo::loadFromJsonFile("app-info.json"); $webAuth = new dbx\WebAuthNoRedirect($appInfo, "PHP-Example/1.0"); $authorizeUrl = $webAuth->start(); $accessToken = '<ACCESS_TOKEN>'; //secret $dbxClient = new dbx\Client($accessToken, "PHP-Example/1.0"); $f = fopen("tufek.jpg", "w+b"); $fileMetadata = $dbxClient->getFile("/tufek.jpg", $f); /*I cant download*/ fclose($f); print_r($fileMetadata); $metaData = $dbxClient->getMetadataWithChildren("/"); foreach($metaData['contents'] as $file){ // I can list my files $f = str_replace("/", "", $file['path']); echo "<div style='text-align:center; margin-top:25px;'><li>$f</li></div>"; } - Burak_Cayir8 years agoExplorer | Level 3note : I dont see any error . Just reloading page , I can see my files like a list and no more. I expect download tufek.jpg but no , its not download.
- Burak_Cayir8 years agoExplorer | Level 3and I can see tüfek.jpg details with an array.
- Greg-DB8 years ago
Dropbox Community Moderator
[Cross-linking for reference: https://stackoverflow.com/questions/42690512/download-file-not-working-with-dropbox-api ]
Thanks for following up with the additional information. If you're seeing the file metadata as you describe, that means the API call itself worked.
When using that getFile method like this, the file data is saved to the file object supplied by to the resource $outStream parameter. In your case, that's your $f file object. Once that method completes successfully, you can then read the data from that file, which in your case is at the path "tufek.jpg".
About Dropbox API Support and Feedback
Get help with the Dropbox API from fellow developers and experts.
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!