Home > OS >  Laravel Crud image wont show
Laravel Crud image wont show

Time:10-20

I am creating a user panel in laravel. Here i also want to upload a profile picture. I store the picture in (projectname)/public/storage/profilepicture/(image) but it wont load in my blade file.

  <td><img src="/public/storage/profilepicture/{{$user->picture}}" width="100px"/> </td>

i used this line but it wont show up

CodePudding user response:

// I am using this code to load the image in my blade file

{{ asset('storage/profilepicture/'.$user->profilepicture) }}

// But it wont load. I am using this code to store the image in my controller

$user->profilepicture = $request->file('profilepicture')->store('profilepicture');

// I am using this code to store the image in my model

public function getProfilepictureAttribute($value)
{
    return asset('storage/'.$value);
}

// I am using this code to store the image in my blade file

{{ $user->profilepicture }}

// I am using this code to store the image in my blade file

{{ asset('storage/'.$user->profilepicture) }}

// I am using this code to store the image in my blade file

{{ asset('storage/profilepicture/'.$user->profilepicture) }}
  • Related