Skip to content
Advertisement

Issue with Storage on shared hosting

I am deploying my first project on a shared hosting.

I followed this tutorial to deploy the website and turn the public folder into the public_html folder of my hosting plan.

When I upload an image from my website (with storeAs() method), the file is uploaded in the private/storage folder, not the public one (where I would like).

The asset() function try to display the image from public_html/storage.

What can I do ?

Thank you 🙂

My files are like this :

JavaScript

(Laravel 8, trying to be hosted on Hostinger)

The tutorial : https://dev.to/pushpak1300/deploying-laravel7-app-on-shared-hosting-hostinger-31cj

Advertisement

Answer

Ok guys i found the solution !

Here is how to deploy your Laravel project on one shared hosting using public_html folder : https://dev.to/pushpak1300/deploying-laravel7-app-on-shared-hosting-hostinger-31cj

This will work but you can have a problem (like me) with the storeAs() method if you deal with file uploads.

To solve this problem, I edited the MyProject/config/filesystem.php by adding this in the available disks :

JavaScript

Replace PATH with the complete path to your public storage (for example /home/you/domains/mydomain.com/public_html/storage/).

Now, open the controller which manage file upload and edit it like this :

JavaScript

This will upload the request()->image in public_html/storage/uploads/filename.png.

I hope it will help you if you had the same problem as me.

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement