How to Store Uploaded Images in Public folder in Laravel 5.8 and Display them on Shared Hosting

Shafiya Ariff
2 min readJul 16, 2019

This article will provide an approach to storing all the uploaded images in a public folder instead of the default storage path while using a shared server.

Upon uploading an image to a website, the image is by default stored in the Storage directory.The website only has access to the public content so the images have to be stored in a public folder for it to be accessible.

When working on a local server, it’s easy to create a symbolic link between a sub-folder in your storage directory and public directory by using a simple artisan command:

php artisan storage:link

But what if you are using a live server which doesn’t support symbolic links?

No worries!

It’s real simple. You just need to change the storage path!

How do you change the storage path?

Go to config → filesystems.php

Change the storage path of local driver .

From:

To:

This will create sub-folder storage in public folder:

This newly created storage will act as a root directory for storing any uploaded images/files.

How to store images in storage?

image->store(‘images’);

store(‘images’) will create a new sub-folder in storage where all the uploaded images will be saved.

How to display the uploaded images?

<img src=”{{url(‘storage/’.$post->image)}}”>

My image is stored in a database table with a column name ‘image’.Since the images are in a public folder, feel free to use url() instead of asset().

So that’s it folks! Hope this was helpful.Thanks for reading. :)

--

--