I have got user’s images uploaded in Laravel storage. How can I access them and render them in a view?
The server is pointing all requests to
/public, so in order to show the image through Laravel blade view, we have to create a symlink in Mac / Windows that can point the url path from
For Mac users.
It is easy, just type below command (mentioned in Laravel Documentation: File Storage):
php artisan storage:link
Once the symbolic link has been created, you can create a URL to the files using the asset helper in view file:
For Windows users.
You can use the mklink command, but first you need to access Command Prompt in Elevate Mode/Admin.
If you’re using a keyboard with Windows 10 or Windows 8, you can open an elevated Command Prompt quickly from the Power User Menu. Just press the WINDOWS and X keys together and then click on Command Prompt (Admin). Click Yes on any User Account Control messages that might appear.
After you open the Command Prompt (Admin), type below command:
mklink /j [project_folder_path]\public\storage [project_folder_path]\storage\app\public
If successfully created for Windows path, it will show below message:
Junction created for [project_folder_path]\public\storage <<===>> [project_folder_path]\storage\app\public