Home > Blockchain >  Image not showing in View (Laravel Blade file)
Image not showing in View (Laravel Blade file)

Time:09-05

Image is present at the directory: C:\xampp\htdocs\project\ecommerce\public\upload\products\thumbnail > 1743108095211357.jpg

It perfectly opens when i type the URL http://127.0.0.1:8000/upload/products/thumbnail/1743108095211357.jpg

But when i open the view page it does not display there, here is code i am using to display it:

<td><img src="{{ asset('/'.$item->product_thumbnail) }}" style="width: 50px; height: 50px" alt=""></td>

when the page opens in browser and by inspecting the page i have found that the URL it opens in browser is

<img src="http://127.0.0.1:8000/upload/products/thumbnail1743108095211357.jpg" style="width: 50px; height: 50px" alt="">

there is no '/' between thumbnail folder and image name how can i fix this? Thanks!

Also

<td><img src="{{ asset($item->product_thumbnail) }}" style="width: 50px; height: 50px" alt=""></td>

gives same error, no forward slash between folder and file name.

CodePudding user response:

Save it like this.

Controller

Products::create([
    'product_thumbnail' => 'upload/products/thumbnail/'. $fileName
]);
  • Related