Cannot access upload images.
Hi all,
I am trying to view my upload images from database. But it not display. It's there in storage/app/upload/lessons folder.
This is my controller
public function index()
{
$lessons = Lesson::all()->toArray();
return view('admin.lesson.manage', compact('lessons'));
}
This is my view file
<div class="box-body">
<table id="example2" class="table table-bordered table-hover">
<thead>
<tr>
<th>ID</th>
<th>Name</th>
<th>Edit</th>
<th>Delete</th>
</tr>
</thead>
<tbody>
@foreach($lessons as $row)
<tr>
<td>{{$row['id']}}</td>
<td><img src="{{$row['imageUrl']}}" alt="" class="img img-thumbnail"></td>
<td>
<a href="{{route('lessons.show',$row['id'])}}">Edit</a>
</td>
<td></td>
</tr>
@endforeach
</tbody>
<tfoot>
<tr>
<th>ID</th>
<th>Name</th>
<th>Action</th>
</tr>
</tfoot>
</table>
</div>
Right now you just output the relative path, but your browser doesn't understand that. Instead you need to use asset($path) to display the images
<img src="{{ asset($path) }}">
Als when storing files in the storage/app directory you need to symlink that to the public/storage directory.
Documentation: https://laravel.com/docs/5.7/filesystem#the-public-disk
@bobbybouwmann I have add like this.
<img src="{{ asset($row['imageUrl'])}}" alt="" class="img img-thumbnail">
But it's not work... Also I have do "php artisan storage:link".
Please or to participate in this conversation.