Al-Amin Islam
Posted on February 19, 2023
When I started learning Laravel ,first time faced problem to Uploaded file. I used to Laravel package that was very complicated for me . Then I show in Laravel File Storage thats very easy to use . Today I will discuss it. I will try how to store file in my Laravel project simple.
This is exactly how I upload files my project.
Following this step by step :
First go to .env
file and changed below.
APP_URL=http://127.0.0.1:8000
FILESYSTEM_DISK=local to FILESYSTEM_DISK=public
Create a folder inside the storage/app
folder.
Example:
storage/app/profile
Run this command.
php artisan storage:link
Add the following to the controller to store file
use Illuminate\Support\Facades\Storage;
use App\Models\HomePage;
$data = $request->all();
if ($request->file('image')) {
$data['image'] = Storage::putFile('profile',
$request->file('image'));
}
HomePage::create($data);
In this code profile
is folder name where file are upload .
šš Hurry Happy Coding šš
š šŖ š
š©
Al-Amin Islam
Posted on February 19, 2023
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.