Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

webfuelcode's avatar

Post image not found

I uploaded the laravel project on shared hosting. But the images are not showing in the post.

The image address is not the correct path. trying to find this...

What I did to set the public folder?

  1. I simply copied .htaccess file from the public folder and pasted it in the root directory.
  2. Then I renamed the server.php file to index.php

So, what else should I fix to get the correct image path for the image I have saved or going to upload with the new posts, on publuc/uploads/imagename.png

Well, the project is working fine only the image path not correct.

0 likes
5 replies
aleksandrov_l's avatar

Try to use the helper function url() for paths:

<img src="{{ url('publuc/uploads/imagename.png') }}" />
webfuelcode's avatar

How to set this so I can store the image in the correct place...

In filesystem.php

'my_files' => [
            'driver' => 'local',
            'root'   => public_path() . '/uploads',
        ],

What can I put in place of public_path() so the image path will store in the same place and I do not have to modify the rest of the codes on different pages?

Now it continuously storing the image under public' folder even though I have moved the public` folder to root. It creates one and stores it there.

Snapey's avatar

Fix your hosting public should never appear in your urls. Period.

Articles with hacks like this should be removed from the internet but unfortunately there are too many cowboys out there

James_Bhatta's avatar

What I usually do is to keep my project files one level below public_html and copy the content of public to public_html. Then change the following lines as:

require __DIR__.'/../APP_DIR_NAME/vendor/autoload.php';

$app = require_once __DIR__.'/../APP_DIR_NAME/bootstrap/app.php';

Finally create symlink.php with following content:

<?php
$targetFolder = $_SERVER['DOCUMENT_ROOT'].'/APP_DIR_NAME/storage/app/public';
$linkFolder = $_SERVER['DOCUMENT_ROOT'].'/public_html/storage';
symlink($targetFolder,$linkFolder);
echo 'Symlink process successfully completed';

Visit app-domain.com/symlink.php

The downside of this approach is that you should copy the content of public every time you pull from repo (if you have changes is public dir).

Please or to participate in this conversation.