Known issues updated. Learn more

File download using v2 in PHP

TCB Level 2
Level 2


Am trying to download file from dropbox using dropbox api-PHP.

I have a sharelink generated using dropbox api


is "".

Am not able to download file from dropbox using



2 Replies

Re: File download using v2 in PHP


Note that Dropbox does not have an officially supported SDK in PHP, so if you have any SDK specific questions, you will need to ask the developer who authored the SDK. 

It appears that you might be using the "kunalvarma05/dropbox-php-sdk".  If that is the case, I suggest reading their wiki page on Uploading and Downloading files ( as it has some helpful examples.

Looking at your example, there are two ways you can possibly solve your problem.

1)  Because you have already created a shared link with the API, you do not need to use the "download()" method.  The link you have posted above can be downloaded with any PHP library or function for accessing a URL on the web.  The file_get_contents() ( method appears to be a very commonly used approach for downloading a file with a url.

2) Downloading a file does not require creating a shared link first.  If you know the path of the file you wish to download, you can use the path of the file within Dropbox to download directly. Assuming you are using the "kunalvarma05/dropbox-php-sdk", the usage would be:

$dropbox->download(<path of file in dropbox>, <path to save locally>)

Re: File download using v2 in PHP


A third possible solution would be to use the sharing/get_shared_link_file API method.  This takes a "url" parameter that would match the shared link URL in your original post, and will return the raw bytes of the file referenced by the shared link.  This approach would be similar to my suggestion #1 in my previous reply.

API Support

Have a question? Our Dropbox Community is here to help you find an answer!
You won’t have to wait too long for a reply, but why not learn more about the Community while you’re here.

Not the right discussion for you? Find out what else our Community has to say about API Support.

Or, search our Help Center for even more.