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

jcoder02k's avatar

Image not loading and not accessible on the browser

May I know why the image cannot be access on the browser I create a php artisan storage:link so the image I upload it save on my database and save on this folder storage/app/public/images/logo.png and have symlink to storage/images/logo.png? The problem the image it's not loading, I also check on the browser http://0.0.0.0/images/logo.png. I got 404 Not found. I use this to load the image on the page but not working.

My Form: FileUpload::make('logo') ->label('Logo') ->image() ->imagePreviewHeight('72') ->directory('images') ->previewable(true) ->getUploadedFileNameForStorageUsing( fn (TemporaryUploadedFile $file): string => (string) str($file->getClientOriginalName()) ->prepend('site-'), ),

0 likes
24 replies
Snapey's avatar

where is your image on the filesystem?

jcoder02k's avatar

@Snapey are you looking for this ?

'links' => [ public_path('storage') => storage_path('app/public'), public_path('images') => storage_path('app/images'), ],

Snapey's avatar

@jcoder02k no, I want you to look at your folders and see where you put the image

Snapey's avatar

@jcoder02k The first of these should be correct, assuming that the public folder is your document root and you do not have to enter public in your routes

Snapey's avatar

@jcoder02k I don't know because you have not said if your document root is correct

jcoder02k's avatar

@Snapey this is what i have @Lenovo-G480:~/docker/vanilla$ php artisan route:list GET|HEAD / ................................... home › HomeController@index

Route::get('/', [HomeController::class, 'index'])->name('home');

Snapey's avatar

@jcoder02k tells me nothing

In your browser, what does the url look like for one of your pages?

jcoder02k's avatar

@Snapey this is my index page http://0.0.0.0/

        <img src="http://0.0.0.0/build/assets/logo-1752e287.png" alt="Pulsing Image" class="self-center pulse-image" style="transform: scale(1);">       <- this logo is working as this is from build

        <img src="http://0.0.0.0/images/site-logo.png" alt="" title="">     <-- not working from  public/storage/images/ folder

        <img src="http://0.0.0.0/storage/images/site-logo.png" alt="" title="">   <-  I also try this not working

this logo is showing if i put it inside public directory only path: public/site-logo.png not inside storage http://0.0.0.0/site-logo.png <-- this is working

Snapey's avatar

@jcoder02k which would indicate your symlink is not effective

With your file explorer, you should see the same files in storage/app/public/images and in public/storage/images

1 like
jcoder02k's avatar

@Snapey yes the image is there when i add it on storage/app/public/images it create on copy on public/storage/images

Bogey's avatar

Try 0.0.0.0/storage/app/public/images/logo.png

1 like
AddWebContribution's avatar

Please verify the folder permission first. Make sure that the web server has the necessary permissions to read the image file. The file should have readable permissions for the web server user. chmod 644 ..path-to/images/site-logo.png please clear your browser cache, Try 0.0.0.0/images/site-logo.png

1 like
jcoder02k's avatar

@AddWebContribution is this correct? $ chmod -R 644 storage/app/public/images

when i run it i got this results chmod: changing permissions of 'storage/app/public/images': Operation not permitted chmod: changing permissions of 'storage/app/public/images/site-logo.png': Operation not permitted chmod: changing permissions of 'storage/app/public/images/site-favicon.ico': Operation not permitted

jcoder02k's avatar

I install a new laravel app and install storage:link

me@me-Lenovo-G480:~/docker/laravel-app$ php artisan storage:link INFO The [public/storage] link has been connected to [storage/app/public].

I add a sample logo.png on storage/app/public/ so my logo is inside the public folder and create a copy on public/storage folder. I also try to chmod this folder public/storage. What is the correct way to add this to our blade file? Why it's not loading on the browser?

I try several way on the browser and it's not work http://0.0.0.0/public/storage/logo.png http://0.0.0.0/storage/logo.png http://0.0.0.0/logo.png

jcoder02k's avatar

@jlrdw how exactly i will do it? is this correct? ln -s /home/jay/docker/laravel-app/storage/app/public/ /home/jay/docker/laravel-app/public/storage/

jlrdw's avatar
jlrdw
Best Answer
Level 75

@jcoder02k I don't know your correct paths, but ln works.

A suggestion, make a folder under public named img, like public\img, and place an image there and see if the asset helper displays it.

<img src="{{ asset('img') . '/' . $yourimage }}" alt="" class="image">

or

<img src="{{ asset('img') . '/' .  'yourimage.png' }}" alt="" class="image">  // direct

Changing class to your image class, and yourimage to your actual image.

Get this working, then pursue the correct symbolic link.

If above don't work, something is wrong with your setup, but with laravel setup right, it works.

Are you sure you are pointing to public as the document root, if not fix that first.

1 like
jcoder02k's avatar

@jlrdw still not working but this one is working but with broken image. I already see the alt tag example image on the page

< img src="{{ asset('storage/img/logo.png') }}" alt="Example Image" >

I try to modify the filesystem but still not working here's my path directory: /home/jay/docker/laravel-app/storage/app/public/img

my .env APP_URL=http://localhost/ FILESYSTEM_DISK=local

my filesystem.php 'default' => env('FILESYSTEM_DISK', 'local'),

 'local' => [
        'driver' => 'local',
        'root' => storage_path('app'),
        'throw' => false,
    ],

    'public' => [
        'driver' => 'local',
        'root' => storage_path('app/public'),
        'url' => env('APP_URL').'/storage',
        'visibility' => 'public',
        'throw' => false,
    ],

'links' => [ public_path('storage') => storage_path('app/public'), ],

note: this is a fresh install laravel app

jcoder02k's avatar

@jlrdw yes this work i just modify it like this

< img src="{{ asset('storage/' . $yourimage }}" alt="" class="image" >

it work on live site but I have issue loading on my localhost because of my docker.

Please or to participate in this conversation.