This is what i have done to upload my file into in laravel project.
if($request->file()) {
$fileName = time().'_'.$request->file('imageFile')->getClientOriginalName();
$filePath = $request->file('imageFile')->storeAs('products', $fileName, 'public');
$product->featured_image = '/storage/' . $filePath;
}
public disk
'public' => [
'driver' => 'local',
'root' => storage_path('app/public'),
'url' => env('APP_URL').'/storage',
'visibility' => 'public',
],
The file uploaded in storage folder inside app/public/products but when I try to retrieve my file showing 404 error. Even I have created the symbolic link with the public folder but not working. i don't no why but files are not showing inside the public folder. files are only uploading project level or private folder inside storage folder. how I can access the file through a web browser.
First you have create symbolic link
php aritsan storage:link
this will create shortcut storage folder in public folder
so you can access url
asset('storage/products/filename')
in your case it you need to change path while storing
$product->featured_image = $fileName;
so while accessing
asset('storage/products/'.$product->featured_image )