sanduniYW
sanduniYW

Reputation: 733

how to add image in laravel?

I want to know How to add image in laravel. I also know it can do using html/css. But I want to know how to give image path and where put images in laravel(I suppose public img folder in laravel). Please help me.

Thanks in advance.

<img src="(How to give image path??)" alt="" style="width:100%;">

Upvotes: 1

Views: 10261

Answers (4)

Ripon Uddin
Ripon Uddin

Reputation: 714

<img src="{{url('folder_name/file_name_variable')}}" alt="" style="width:100%;">
{{url('folder_name/file_name_variable')}}<br>

try this

Upvotes: 0

Leena Patel
Leena Patel

Reputation: 2453

The storage_path() is OS file system path. For example in Windows it will be C:\project\storage or *nix /var/www/project/storage.

The <img> can't read the OS path. They read URL, something like http://domain/image.png.

For example to read images inside storage_path, add this inside routes/web.php.

Route::get('storage/{name}', function ($name) {

   $path = storage_path($name);

   $mime = \File::mimeType($path);

   header('Content-type: ' . $mime);

   return readfile($path);

})->where('name', '(.*)');

Usage

<img src="{{ get_image('storage/images/logo.png') }}" />
<img src="{{ get_image('storage/images/other.jpg') }}" />

Upvotes: 0

sanduniYW
sanduniYW

Reputation: 733

I solved my problem as following:

<img src="img/pictureName.jpg" alt="">

img is folder in public.I only give path in image simply.

Thanks all.

Upvotes: 1

Abdenour Keddar
Abdenour Keddar

Reputation: 121

You need to store your images in the public folder and then you can access them like this

{{ asset('/my-picture.png') }}

You can also access them using Laravel Collective package for building forms and HTML elements, so your code will look like this:

{{ HTML::image('/my-picture.png', 'about the picture') }}

Upvotes: 1

Related Questions