I have been struggling with this problem for quite a few hours. My problem is that I have an image url saved in my database and when i retrieve it I try to display it in my index.blade.php. The weird part is I had used the same code in an older project and it worked, but I turned on the older project and it does not work there anymore either. I have done php artisan storage:link and from what i see the link is correct but the images are displayed as broken, I have looked up various solution but all of it lead to a dead end, because the url just doesnt want to display the image. The image url is saved in this form http://127.0.0.1:8000/storage/public/vsX9ihmRknGWLXtNRmxgCXV3ckqhlFoBlyuMoejB.png
My index.blade.php tbody
<tbody>
@foreach($companies as $company)
<tr>
<td scope="row">{{$company->id}}</td>
<td>{{$company->name}}</td>
<td>{{$company->email}}</td>
<td><img class="class='img-fluid rounded mb-3 mb-lg-0 ml-md-0" src="{{$company->logo}}"></td>
<td>{{$company->url}}</td>
<td>
<a href="{{route('company.edit', $company->id)}}" class="float-left">
<button type="button"
class="btn btn-primary mr-2">{{__('Edit')}}</button>
</a>
<form action="{{route('company.delete',$company->id)}}" method="POST"
class="float-left">
{{method_field('DELETE')}}
@csrf
<button type="submit"
class="btn btn-danger btn-sn">{{__('Delete')}}</button>
</form>
</td>
</tr>
@endforeach
</tbody>
How I call it from my Companiescontroller
public function index(): Renderable
{
$companies = $this->company->all();
return view('company.index', compact('companies'));
}
How I store my image url
public function store(Request $request): RedirectResponse
{
$request->validate([
'name' => 'required',
'email' => '',
'logo' => 'dimensions:min_width:100,min_height:100',
'url' => ''
]);
$parameters = $request->all();
if ($request->logo !== null) {
$image = $request->logo->store('public');
$parameters['logo'] = URL::to('/') . '/storage/' . $image;
}
$this->company->create($parameters);
return redirect()->route('company.index');
}
I am not sure if this is enough, but i guess these are primary parts.
php artisan storage:linkcreate a symlink withstorage/app/publicso move your image fromstorage/publictostorage/app/public. Then you can access throughhttp://127.0.0.1:8000/storage/vsX9ihmRknGWLXtNRmxgCXV3ckqhlFoBlyuMoejB.png