The thing is, my image is not directly present in my view
Route::Get('saakshar',function()
{
return view('version1');
});
and in my version1.blade.php
<?php
include(app_path()."/../resources/views/fronthead.blade.php");
?>
I know using php commands in blade file is not efficient or good in any manner, but blade command is not working, but that's not my main problem here.
and in my fronthead.blade.php
<img src='app_path()."/../resources/views/photos/logo.png"' alt="no logo">
I haven't learned fully the blade language, so for time being i am using php commands.
But my problem is, why isn't the photo loading in the webpage? Is the URL wrong? Did I place the "photos" folder in the wrong place?
Edit: I've even tried to place the photo is the same folder as fronthead.blade.php and changed the src tag.
I've even tried giving a separate Route::Get() from fronthead.blade.php, but still the problem persists.
You should store your images, css and JS files in a public
directory. To create a link to any of them, use asset()
helper:
{{ asset('img/myimage.png') }}
https://laravel.com/docs/5.1/helpers#method-asset
As alternative, you could use amazing Laravel Collective package for building forms and HTML elements, so your code will look like this:
{{ HTML::image('img/myimage.png', 'a picture') }}
If Image folder location is public/assets/img/default.jpg.
You can try in view
<img src="{{ URL::to('/assets/img/default.jpg') }}">
<img src="/images/yourfile.png">
将您的文件存储在 public/images 目录中。
normaly is better image store in public folder (because it has write permission already that you can use when I upload images to it)
public
upload_media
photos
image.png
$image = public_path() . '/upload_media/photos/image.png'; // destination path
view PHP
<img src="<?= $image ?>">
View blade
<img src="{{ $image }}">
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.