How display image in laravel 5.3

冷暖自知 提交于 2020-02-02 04:53:50

问题


I store image in public folder now i want to display the image i give the path but image not show any one help me whats the wrong in my code

My image complete path is public/admin/product

<img src="public/admin/product/<?php echo $productr['image'];  ?>" height="30px" width="30px">

回答1:


Laravel view files blade.php supports {{}} tags to display values.

{{ $valueToBeDisplayed }}

In your case, you can do like

<img src="/admin/product/{{ $product['image'] }}" height="30px" width="30px" />

Assuming image name is abc.png.

Make sure you have that image in folder public/admin/product/abc.png




回答2:


remove public from your path.., also, you might have typos on the variable $productr, (did you mean $product?) try

<img src="admin/product/<?php echo $product['image'];  ?>" height="30px" width="30px">

or, using blade standard:

 <img src="admin/product/{{ $product['image']; }}" height="30px" width="30px">



回答3:


First thing, you should not store those images inside public directory. Instead you should use Storage directory. Please have a look to the Laravel documentation:

https://laravel.com/docs/5.3/structure#the-storage-directory

So, upload such images inside "storage/app/public"

Then fire below artisan command to create symbolic link:

php artisan storage:link

And then create a link to that image:

<img src="{{ echo asset('storage/file.png') }}" height="30px" width="30px">



回答4:


@if ($productr['image'])
<img src="{{ asset('images/profile/'.$productr['image']) }}" alt="{{ $category->user->image }}">
@else
<img src="{{ asset('assets/dist/img/default-150x150.png') }}" >
@endif



回答5:


hope this will help

{{ asset('public/imagepath/image_name') }}


来源:https://stackoverflow.com/questions/40989290/how-display-image-in-laravel-5-3

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!