Get files or images from outside the project folder using storage in laravel, we will change to a custom image file path in the filesystem configuration.
I want to get files from outside applications from another directory, also i want to get a file using a storage public disk.
My File Located
My image file is located in the below-given file path, So I will put this file path in the filesystem configuration.
"/var/www/html/images/logo.png"
Change Path In Config
I put this path in the filesystems.php
config/filesystems.php
'disks' => [
'local' => [
'driver' => 'local',
'root' => storage_path('app'),
],
'public' => [
'driver' => 'local',
'root' => '/var/www/html/images/', // CUSTOME IMAGES FILE TO OUTSIDE PROJECT
'url' => '/var/www/html/images/', // CUSTOME IMAGES FILE TO OUTSIDE PROJECT
'visibility' => 'public',
],
's3' => [
'driver' => 's3',
'key' => env('AWS_ACCESS_KEY_ID'),
'secret' => env('AWS_SECRET_ACCESS_KEY'),
'region' => env('AWS_DEFAULT_REGION'),
'bucket' => env('AWS_BUCKET'),
'url' => env('AWS_URL'),
'endpoint' => env('AWS_ENDPOINT'),
'use_path_style_endpoint' => env('AWS_USE_PATH_STYLE_ENDPOINT', false),
],
],
Basic Usage
Now my storage public disk file path is "/var/www/html/images", So when I pass the image name as in the below given example, the image will fetch from the given file path outside the project.
Storage::disk('public')->url('logo.png');
We always thanks to you for reading our blogs.
Dharmesh Chauhan
(Swapinfoway Founder)Hello Sir, We are brothers origin from Gujarat India, Fullstack developers working together since 2016. We have lots of skills in web development in different technologies here I mention PHP, Laravel, Javascript, Vuejs, Ajax, API, Payment Gateway Integration, Database, HTML5, CSS3, and Server Administration. So you need our service Please Contact Us
Haresh Chauhan
(Co-Founder)We Are Also Recommending You :
- Laravel Event Broadcast With Redis Socket.io Echo To Listen Real-Time Message
- Default index.php Root Path Change And Remove Public From The Url
- Laravel Delete Image From Storage Folder
- laravel cache clear command
- Laravel 6 validation with error message
- Laravel 10 Firebase Web Push Notification Tutorial
- How To Secure Laravel Website From Hackers
- Laravel 10 CRUD Operation With YouTube Video Tutorial
- All Know About Different Root Path Of The Laravel Application With Example
- Laravel Pagination Not Working While Using Map Method [solved]