upload file in public folder by storage function in Laravel 8
//filesystems.php
'disks' => [
'uploads' => [
'driver' => 'local',
'root' => public_path() .'/upload',
'visibility' => 'public',
]
]
//My-project(Laravel)\public\upload\images\blogs
use Validator;
use file;
use Illuminate\Support\Facades\Storage;
$request->validate([
'featured_image' => 'required|max:2048',
]);
$name = $request->file('featured_image')->getClientOriginalName();
$file_path = $request->file('featured_image')->storeAs('images/blogs', $name, 'uploads');
Comments
Post a Comment