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

rehman_ali's avatar

Image is not showing on view Laravel

I am facing issue with image. Image is being stored at directory :

<img src="{{ asset("storage/$post->image") }}" width="1000" height="500">

but when I try to display image on webpage. It is being fetched from:

/storage/images/posts/7PxSl786DpTzl1Txtebv3sYInKzVDnLiMRBx9u9R.png" The error on console is:

Failed to load resource: the server responded with a status of 404

When I run command: PHP artisan storage:link it says: The [D:\New folder\htdocs\blog-cms-main\public\storage] link has been connected to [D:\New folder\htdocs\blog-cms-main\storage\app/public].

I don't know what is the problem. I hope I have added all the information that could be required. Any help would be apperciated.

0 likes
9 replies
Sabonzy's avatar
Sabonzy
Best Answer
Level 9

@rehman_ali Have you checked the directory to see if the folder structure is correct and if the file exists in the folder?

I suggest you delete the symbolic link from the public folder and run the command PHP artisan storage:link again.

Normally I would create a dedicated disk like post

'disks' => [

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

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

];

then you can store the image like so

$path = Storage::disk('post')->putFile('', $request->file('postImag')); 

or through the request object

$path = $request->file('postImag')-> storeAs( '','filename', 's3');

you can also create a method on the Post model to access the image url like so

public function imageUrl()
    {
        return Storage::disk('posts')->url($this->image);
    }

then you can access it in the view like so <img src="{{$post->imageUrl() }}" width="1000" height="500">

Caleb Pozio the creator of Livewire explains this concept in a video here better: https://laravel-livewire.com/screencasts/s5-filesystem-disks

ali321213's avatar

@Sabonzy Thank you so much, man! Your suggestion really helped me a lot. I was completely stressed about this issue. I recently started programming in Laravel and have been building an eCommerce store. For an entire week, I struggled with product images not showing in the table—they were getting stored but wouldn’t display. I tried everything, but nothing worked.
After following your advice, I deleted the symbolic link and ran the command php artisan storage:link again, and finally, the images appeared in the table. I can't thank you enough!

mate89's avatar
  1. The $post->image is string? it contains the filename which you would like to display?
  2. The symlink has created successfully? In the case of Windows, there may be problems with the symlink.
  3. The image which you would like to display is exists on the place where you looking for?
kokoshneta's avatar

As @mate89 mentions, symlinks can be a bit of a bother on Windows. In the storage:link output you posted, I notice there are both backslashes and forward slashes – this may be an indicator that the symlink has not been correctly created.

Have you tried manually creating the symlink instead of doing it via Artisan?

Also, you say, “but when I try to display image on webpage. It is being fetched from [URL]”. Since you use the word ‘but’, I assume that isn’t the expected URL. But then what is the expected URL? Where is the image actually located?

Snapey's avatar

your image should be stored in the storage/app/public folder. Is it ?

If will then appear because of symlinking in the /storage folder on the public side

rehman_ali's avatar

@Snapey Image is stored at D:\New folder\htdocs\blog-cms-main\storage\app\images\posts I have checked. An in console the image is fetched from: <img src="http://localhost:8000/storage/images/posts/OrboaWVorMV373VHhQAGCtqQq4q8IF8z82KHZAj2.png" width="1000" height="500"> Code in view is: <img src="{{ asset("storage/$post->image") }}" width="1000" height="500"> Now I don't have any clue why is it happening. I have run command for storage link. Sharing code from filesystem.php so that maybe you can get better idea where the problem is:

'disks' => [

        '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'),
    ],

];

I removed some code that i believe is irrelevant like s3 block.

Please or to participate in this conversation.