Need to see if your shared folder is taking up space on your dropbox 👨💻? Find out how to check here.
Forum Discussion
Stefano B.3
10 years agoNew member | Level 1
Upload file directly on dropbox
HI ,sorry for english, Im learning about upload a file on server to dropbox .
[code]
<?php require_once "dropbox-sdk/Dropbox/autoload.php";
use \Dropbox as dbx;
$accessToken='My_access_...
Greg-DB
Dropbox Community Moderator
10 years ago[Cross-linking for reference: https://stackoverflow.com/questions/38935509/dropbox-upload-file ]
It looks like you're using the PHP Core SDK for the deprecated API v1. We recommend migrating to API v2 whenever possible. We don't have an official PHP SDK for API v2, but there are some third party ones listed here.
Anyway, to answer your questions:
1) That uploadFile method will return the metadata for the uploaded file if the upload was successful, and will raise an exception if not.
2) Using the PHP Core SDK, you'll need to have the data on your server in order to upload it. Assuming this is a web app though, you could upload it directly from the user's browser, but you'd have to build that integration in JavaScript. We are working on a JavaScript SDK for API v2.
Alternatively, if you have a URL for the file you want to upload from somewhere, you can upload the file to Dropbox using that URL without passing the data through your server. On API v1, you would use /save_url for that, but it's unfortunately not implemented in the PHP Core SDK. On API v2, you would use /files/save_url.
3) Yes, you can create folders using the API. E.g., in the PHP SDK, you would use the createFolder method. You don't actually need to explicitly create parent folders when uploading files though. For example, if you upload a file to /Documents/myfile.docx, the "Documents" folder will automatically be created if it doesn't already exist.
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!