0
votes

I deployed a Laravel 5.5 application on shared hosting and I have a problem with uploading/viewing images.

Everything is working well on localhost but when I upload it online I can't access the directory where my images are stored.

Here is where is store my images

$destinationPath = public_path('items/'.$request->get('modal-item-id'));

And it is storing image in :

public_html/nbd/public/items/307/my-image.png

Also here is my filesystems.php settings for 'images':

'images' => [
    'driver' => 'local',
    'root' => public_path('items'),
    'url' => env('APP_URL').'/items',
     visibility' => 'public',
],

My app is located in

public_html/nbd/system

...and because I had to put PUBLIC folder out of the systems folder (shared hosting) now I can't access the image on https://my-url/system/public/items/307/my-image.png

How can I access that file? Where did I make a mistake?

1
as you can see my app folder is not inside public_html, it is already in separate folder called NBDAleksandar Đokić

1 Answers

2
votes

You should not run the full Laravel under a webserver document root which is in your case ./public_html more point the documentroot of the webserver to ./public_html/nbd/system/public -> and you will be able to access http://your-domain/items/307/my-image.png

But in your case you cannot access due missing folder nbd -> https://my-url/nbd/system/public/items/307/my-image.png