I am making a laravel application to serve as a backend to my website. I have an image (images) stored in a postgresql database. The format is bytea. I now want to display this image but it is showing me an error message.
Facade\Ignition\Exceptions\ViewException htmlspecialchars() expects parameter 1 to be string, resource given (View: C:\wamp64\www\WebTech\resources\views\shop\index-temp.blade.php)
I can't figure out whats wrong. Here is the code that is producing this error.
@foreach($productsList as $product)
<div class="col text-center">
<a href="/products/{{$product->id}}">
<img class="img-fluid" srcset="{{ $product->image_200 }} 200w, {{ $product->image_300 }} 300w"
sizes="(max-width: 480px) 200px, 300px"
src="{{ $product->image_300 }}" alt="{{ $product->alt_text }}">
<p class="mb-0 text-center text-white">{{ $product->name }}<br>{{ $product->cost }} eur</p>
<p>{{$product->image_200}}</p>
</a>
</div>
@endforeach
For clarification, the columns image_200, image_300 and image_500 are in bytea format in postgresql database.
I have tried using the pg_unescape_bytea({{ $product->image_300 }}) function, but it doesn't help. What is the correct way to display an image in this way?
{{ pg_unescape_bytea($product->image_300) }}if you were trying to do what you had tried