The thing is, my image is not directly present in my view

Route::Get('saakshar',function()
{
return view('version1');
});

在我的版本1中.刀身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.

在我的前脑.刀身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.

但我的问题是,为什么照片没有加载到网页中?网址错了吗?我把"照片"文件夹放错地方了吗?

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:

<img src="{{ asset('img/myimage.png') }}" alt="description of myimage">

https://laravel.com/docs/5.1/helpers#method-asset

作为替代方案,您可以使用惊人的Laravel Collective包来构建表单和HTML元素,因此您的代码如下所示:

{{ HTML::image('img/myimage.png', 'a picture') }}

Laravel相关问答推荐

Laravel 通过 API 嵌套 url 发布

V-icon 在 Vuetify 3 中不显示图标

嵌套数组请求的 Laravel 验证,其中如果整数之一为零,则另一个应大于零

Laravel Eloquent:组合列(或自定义属性)上的 Where 子句

如何在 laravel livewire 中按 bool 值排序数组

Laravel 连接表

在 apache docker 容器中运行虚拟主机

Laravel 重定向数据不工作

.gitignore 不忽略文件夹

Eloquent 的集合方法,例如 only 或 except 返回一个空集合

为什么我的 Laravel 队列作业(job)在 60 秒后失败?

file_put_content ...无法打开流:Laravel 5 中的权限被拒绝

Laravel 将参数从路由传递到过滤器

如何更改 ember-cli 中的 dist 文件夹路径?

在 Laravel 5 中找不到类App\Http\Controllers\Artisan

如何在 Laravel 视图中找到当前语言?

如何在 Laravel 4 中组织不同版本的 REST API 控制器?

Laravel 表:只能有一个自动列,并且必须定义为键

如何在 Laravel 测试中禁用选定的中间件

Laravel Eager加载与显式连接