P
P
paulvales2015-06-03 09:46:37
PHP
paulvales, 2015-06-03 09:46:37

How to download a file from DropBox using PHP?

Hello, uploading to the cloud:
quire_once "lib/Dropbox/autoload.php";
use \Dropbox as dbx;
$accessToken = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"; // Your Access token is
here $dbxClient = new dbx\Client($accessToken, "PHP-Example/1.0");
// allowed formats
if(isset($_FILES['upl']) && $_FILES['upl']['error'] == 0){
$fbuch=$_FILES['upl']['tmp_name'];
$f = fopen($fbuch, "r+");
$fbuch2="/".$_FILES['upl']['name'];
$fileMetadata = $dbxClient->uploadFile($fbuch2, dbx\WriteMode::add(), $f);
fclose($f);
}
How can I download a file? or get a link to it. I also heard about createShareableLink but this function also does not work

Answer the question

In order to leave comments, you need to log in

3 answer(s)
O
OnYourLips, 2015-06-03
@OnYourLips

https://www.dropbox.com/developers/core/start/php

P
paulvales, 2015-06-03
@paulvales

Tried with
$f = fopen("working-draft.txt", "w+b");
$fileMetadata = $dbxClient->getFile("/working-draft.txt", $f);
fclose($f);
print_r($fileMetadata); displays only an array of metadata, but I don’t know how to proceed further

V
Vitaly Khomenko, 2015-06-03
@iiifx

Try Flysystem: flysystem.thephpleague.com/adapter/dropbox
Methods to work: flysystem.thephpleague.com/api

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question