public function dropbox::add in Dropbox Client 7.2
Same name and namespace in other branches
- 7.4 dropbox.php \dropbox::add()
- 7 dropbox.php \dropbox::add()
- 7.3 dropbox.php \dropbox::add()
Adds a local file to the authenticated user's dropbox account using the post method
Parameters
string $dbpath The location in the user's dropbox to place the file.:
string $filepath The relative path on the server of the file to upload.:
array $params (optional) Consult the Dropbox API documentation for more details:
string $root Either 'dropbox' or 'sandbox':
Return value
a response object
File
- ./
dropbox.php, line 218
Class
Code
public function add($dbpath, $filepath, array $params = array(), $root = 'dropbox') {
$dbpath = str_replace(' ', '%20', $dbpath);
$filename = rawurlencode($filepath);
$parstr = empty($params) ? '' : '&' . http_build_query($params);
$uri = preg_replace("#(^|[^:])//+#", "\\1/", "/files/{$root}/{$dbpath}?file={$filename}{$parstr}");
$specialhost = 'api-content.dropbox.com';
return $this
->_post_request($uri, array(
'file' => '@' . $filepath,
), $specialhost);
}