Source: nemanjacoder.medium.com

Using Dropbox as storage for Laravel

Category: Laravel, api, git

Other important things that you need to know: The first solution and simplest one I came up with is to upload pictures inside a public folder, save the path in database and then simply use that path in blade in tag to display it. When an Admin changes a picture, I would first delete the old one and then save the new one.

To use something else, you need to register a driver for that storage.For Dropbox, first you need to install dependency for drivercomposer require spatie/flysystem-dropboxProject configurationThe next step is to configure your project, so it can use Dropbox- In file config/filesystems.phpdeclare a new driver

Upload photoIn method where you upload file simply use Storage class to upload file to Dropbox, also when editing you first check if image exists, then delete it and then put new one.Put method returns filename which you should store in database and use it later for download. Download and display imageFirst create new get route for download and in method in controller add: Then in blade just use download link with image path in your img tag image)}}” alt=””>44 4AboutHelpLegal
Newsletter

Get the latest Laravel/PHP jobs, events and curated articles straight to your inbox, once a week

Fathom Analytics | Fast, simple and privacy-focused website analytics. Fathom Analytics | Fast, simple and privacy-focused website analytics.
Achieve superior email deliverability with ToastMail! Our AI-driven tool warms up inboxes, monitors reputation, and ensures emails reach their intended destination. Sign up today for a spam-free future. Achieve superior email deliverability with ToastMail! Our AI-driven tool warms up inboxes, monitors reputation, and ensures emails reach their intended destination. Sign up today for a spam-free future.
Community Partners