- Laravel Version: 8.35.1
- PHP Version: 8.0.0
Description:
I'm uploading an image with laravel using this code:
$product_image = $request->file('product_image');
$product_image_extension = $product_image->extension();
$product_image_name = time() . '.' . $product_image_extension;
$product_image->storeAs('/media/product_images', $product_image_name);
$model->product_image = $product_image_name;
It works fine, the file is uploaded to storage/app/media/product_images/.
Then, I run the command
php artisan storage: link
to create the symlink in public. The Command Execute Like this:
Local NTFS volumes are required to complete the operation.
The [E:\Complete Programming Bootcamp\laravel Work\ecom-project\cyber_shopping\public\storage] link
has been connected to [E:\Complete Programming Bootcamp\laravel Work\ecom-
project\cyber_shopping\storage\app/public].
The links have been created.
I am Using This Code To Display Image:
{{asset('storage/media/product_images/' . $list->product_image)}}
But Image is not displaying on the frontend.
Also, The Storage Folder Is not created in the public folder. PLz, Help Me.
Thanks
storage/app/public/media/product_images/
to make them publicly accessibles throughasset('storage/media/product_images/' . $list->product_image)
. So change$product_image->storeAs('/media/product_images', $product_image_name);
to ` $product_image->storeAs('public/media/product_images', $product_image_name);` – porloscerros Ψ