I know a lot of threads have been made about this in the past, but after much searching I cannot find one that is recent and adequately explains how to retrieve images you have saved to storage.
I am uploading avatar images to to the avatars folder, which means they are being stored in storage/app/avatars. I am then adding the path returned by the store method to a column in the user database. This value looks like avatars/j4yZcfzSSJnRONYKaiTUZTrQp5UaDQfSSnrZ5i8G.jpeg.
Simply put, how do I access the URL to this image such that I can display the image? Some threads say to store the file in a different directory, some say to create a link of some sort. I want to know how to do this the right way because this is a task I do quite often. After scouring the documentation, I cannot seem to find what I'm looking for in simple enough terms.
I did read about that solution, but it says it is not possible to use on most shared hosting platforms. This is a great concern for me because most likely the website I am working on will be running on shared hosting.
Why is it the case that this will not work on shared hosting? I mean, a folder is a folder and if the folder is located on my server it seems like it should be able to access it. Perhaps I'm misunderstanding the storage aspect of Laravel.
And in the case that it cannot be used on shared hosting, what alternative would you recommend? Simply storing the file in the public folder?
It depends on the hosting service. Some shared hosting will allow symlinks, others won't. It could be a massive security hole if the host lets you use symlinks that reference something in another users space.
Another option would be to use a S3 bucket for your uploads so they aren't even stored on your server. I'd probably lean towards this route anyway.
Another option is to change your storage for avatars.
@Cronix Sorry for the late reply, but this appears to be exactly the answer I was looking for. I'll report back if I run into any issues, but for now I will mark you as correct answer.