Guide to Link Storage Folder to Public
Step 1: Ensure You Have the Public Disk Configured
By default, Laravel’s filesystem configuration is located in config/filesystems.php
. Make sure the 'disks'
array contains the following public disk configuration:
Step 2: Run the Artisan Command
Execute the following command to create a symbolic link from storage/app/public to public/storage:
Step 3: Verify the Storage Link
Once the command runs successfully, check if the storage folder is now accessible inside the public
directory:
You should see a symbolic link named storage pointing to storage/app/public
.
Step 4: Store and Access Files in Public Storage
Now, you can store files in the storage/app/public directory and access them via the URL /storage/{filename}
.
Example of storing a file in the public disk:
Step 5: Ensure the Correct Permissions (If Needed)
If the storage link is not working, set the correct permissions:
Step 6: Clear Cache (If Still Not Working)
If the storage link is still not accessible, clear Laravel's cache:
Conclusion
Now, your storage folder is successfully linked to the public directory, allowing you to access stored files via the public/storage
URL. Let me know if you need any further assistance!