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 Carbon diffForHumans Arguments Passing
- How To Get Current Request Method Post Patch Get In Laravel - PHP
- How To Insert Big Data In The Database Laravel?
- How To Clone Laravel
- Laravel Logs Viewer Integration
- Laravel 10 Forum Integration Tutorial Example
- How To Get Youtube Video Thumbnail From URL In PHP - Laravel
- How To Generate A Sitemap In Laravel 6/7/8/9
- How to Get Browser Name and Version in Laravel
- How to Make/Create/Write JSON File Using PHP Array In Laravel - PHP