Dropbox is an American firm that provides file hosting services. They offer personal cloud software, file syncing, and cloud storage. Today, Dropbox is a widely popular option for cloud storage and file synchronization. Large files can be stored and shared on Dropbox, and database backups can also be kept there. Most individuals choose for Dropbox while using cloud storage.

I'll demonstrate how to upload a file to our Dropbox account using the league/flysystem-dropbox package in this post. Additionally, we receive the share and view links for uploaded files, allowing us to keep them in databases if necessary. In this post, I'll show you a straightforward example of utilizing the Dropbox Client API to store a file in your account. You only need to follow a few simple steps to run an example.

Installation Package

In order to use the Dropbox Client API method, we must first install the league/flysystem-dropbox package. To do this, perform the following command.

composer require league/flysystem-dropbox

Token and Secret Configration

To obtain the token and secret, we must first build an app on the Dropbox website; if you don't already have an account, you may do so here: Create App.

You can find a secret and a token after creating a new app. You must duplicate it and then continue. env file this way:



Create route and controller

For a straightforward example so that you can fully grasp, we must establish a route and controller in this stage. Create a route in this manner initially.


Route::get('dropboxFileUpload', 'HomeController@dropboxFileUpload');

Now that your HomeController has been added, let's look at an example. In this example, I have an img folder on the public folder with an admin.png image inside of it. When I run this example, my Dropbox account will receive the file:


namespace App\Http\Controllers;

use App\Http\Requests;
use Illuminate\Http\Request;
use Dropbox\Client;
use Dropbox\WriteMode;

class HomeController extends Controller
     * Create a new controller instance.
     * @return void
    public function __construct()

    public function dropboxFileUpload()
        $Client = new Client(env('DROPBOX_TOKEN'), env('DROPBOX_SECRET'));

        $file = fopen(public_path('img/admin.png'), 'rb');
        $size = filesize(public_path('img/admin.png'));
        $dropboxFileName = '/myphoto4.png';

        $Client->uploadFile($dropboxFileName,WriteMode::add(),$file, $size);
        $links['share'] = $Client->createShareableLink($dropboxFileName);
        $links['view'] = $Client->createTemporaryDirectLink($dropboxFileName);


Run the given example and see the results.

Recommended Posts

View All

Laravel 9 Captcha Tutorial – Create Captcha in Laravel

A CAPTCHA is a challenge-response test used in computing to determine if a user is human. It is an abbreviation for the Completely Automated Public Tu...

Laravel 8 Generate PDF with Graph Tutorial

Laravel 8 generates a graphed pdf. You will understand how to generate a pdf with a graph in the Laravel 8 app in this tutorial

PayPal Integration in Laravel Example

PayPal Integration in Laravel, laravel paypal integration, laravel setup paypal, laravel paypal integration example

Laravel 9 Upload image using Summernote editor

A basic Javascript package called Summernote Editor can be used to create online WYSIWYG web editors.

Laravel Routing Tutorial Step by Step

I'll give you a step-by-step instruction on laravel routing in this blog. We'll demonstrate how to make a new route in Laravel and how to make a route...