prince69's avatar

Image is not display in server but in localhost works fine

Image in not shown on sever but in locally, It wokrs perefect. In this way, I store image

    if ($request->has('image')) {
        $filename = $request->image->getClientOriginalName();
        $request->image->storeAs('avatar/users/', $filename, 'public');
    }

Here is in view blade

  <img src="{{ asset('/storage/avatar/users/' . auth()->user()->image) }}" >

In locally that works fine but when I upload my project on server, image is not displayed. Can anyone tell me why did it happen? & how to solve it?

0 likes
11 replies
chaudigv's avatar

To make these files accessible from the web, you should create a symbolic link from public/storage to storage/app/public.

To create the symbolic link, you may use the storage:link Artisan command:

php artisan storage:link

Also make sure the storage folder permission is 755

prince69's avatar

I run this command & I got this "link already exists." . But still image is not showing

1 like
chaudigv's avatar

Any console errors like image not found?

prince69's avatar

yes, console error "404 image not found"

1 like
CorvS's avatar

@prince69 What exactly does your "server" look like? Is it a DigitalOcean droplet? Do you even have the permission to write to the filesystem of said server? Did you check inside your storage folder if the file actually exists?

Snapey's avatar

you ran this command on your webserver? (not just locally)

prince69's avatar

I ran this command locally, then upload it again in server. There is no option to run command in my webserver

AlexandruC's avatar

Have the same problem -> Image from storage (with symbolic link) works well on local, but not on server.

Displaying a simple pictures from storage is a known bug? Have anyone managed to solve this?

Snapey's avatar

@AlexandruC Its not a known issue. Its a problem specific to your installation. Please start your own question with your own circumstances.

Please or to participate in this conversation.