Curious about A, B, C, and D drives? Learn what they mean and how to use them effectively with Dropbox in this handy guide! - check it out now!
Forum Discussion
toki4004
2 years agoHelpful | Level 5
Upload string value to file - PHP
I need to upload a simple string via api - there is no "file" on the server - the string will be generated in my PHP code. First, does it need to be in binary? Second, when I upload, I get a "1" writ...
- 2 years ago
The /2/files/upload endpoint is a "content-upload" style endpoint, meaning that it expects the raw bytes of the file data in the HTTPS request body (with corresponding "application/octet-stream" type, as you have).
Exactly how you retrieve that data and configure your HTTPS client to send it like that is up to you. Please note that we can't provide support for configuring third party clients themselves, as they're not made by Dropbox, so you may need to refer to the documentation for the client you're using for information on how to configure it.
That said, looking at the code you shared, it looks like you might want to do the following, instead of your current 'CURLOPT_POSTFIELDS' and 'CURLOPT_INFILE' usage:
curl_setopt($ch, CURLOPT_POSTFIELDS, $string);
Greg-DB
Dropbox Staff
2 years agoThe /2/files/upload endpoint is a "content-upload" style endpoint, meaning that it expects the raw bytes of the file data in the HTTPS request body (with corresponding "application/octet-stream" type, as you have).
Exactly how you retrieve that data and configure your HTTPS client to send it like that is up to you. Please note that we can't provide support for configuring third party clients themselves, as they're not made by Dropbox, so you may need to refer to the documentation for the client you're using for information on how to configure it.
That said, looking at the code you shared, it looks like you might want to do the following, instead of your current 'CURLOPT_POSTFIELDS' and 'CURLOPT_INFILE' usage:
curl_setopt($ch, CURLOPT_POSTFIELDS, $string);
toki4004
2 years agoHelpful | Level 5
Yes, that worked! Thanks,
About Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.5,955 PostsLatest Activity: 2 hours ago
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 or Facebook.
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!