Question

am trying to learn dropbox php-api. i have done upload, but unable to create a new folder(if not exist) in dropbox account

code snippet :

// Create new directory
$create_new_folder = $dropbox->createFolder('new_folder','dropbox');

// Create a temporary file and write some data to it
$tmp = tempnam('/tmp', 'dropbox');
$data = 'This file was uploaded using the Dropbox API!';
file_put_contents($tmp, $data);

// Upload the file with an alternative filename
$put = $dropbox->putFile($tmp, 'abc.txt');

// Unlink the temporary file
unlink($tmp);

// Dump the output
var_dump($put);

error:

Call to undefined method Dropbox\API::createFolder() in C:\wamp\www\BenTheDesigner-Dropbox-b49576c\examples\putFile.php on line 18

Was it helpful?

Solution

This error seems to be indicating that you are trying to call a function named "createFolder" that doesn't exist. Checking the library at:

https://github.com/BenTheDesigner/Dropbox/blob/master/Dropbox/API.php

It looks like the function is actually just named "create":

/**
 * Creates a folder
 * @param string New folder to create relative to root
 * @return object stdClass
 */
public function create($path)
{

OTHER TIPS

just use it

require_once('bootstrap.php');

// Create new directory $create_new_folder = $dropbox->create('docs','dropbox');

now check in your dropbox :)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top