php - 图片未显示在网页中(带有 Laravel 的 PHP),其他代码工作 100% 正常
问题描述
我的代码工作正常并显示存储在数据库中的内容。但不显示存储在以下位置的图像:C:\xampp\htdocs\Task_List\storage\app\fileToUpload
显示数据控制器.php
class DisplayDataController extends BaseController
{
public function displaydata()
{
$users = DB::table('users')->select('id','email','password','pic')->get();
return view('displaydata',['users'=> $users]);
}
}
网页.php
Route::get('/', 'DisplayDataController@displaydata' );
显示数据.blade.php
<html>
<head>
<title>
Display Data
</title>
</head>
<body>
<fieldset>
<legend>User Records</legend>
<table>
<thead>
<tr>
<th>ID</th>
<th>Name</th>
<th>Password</th>
<th>Image</th>
</tr>
</thead>
<tr>
@foreach($users as $user)
<td>{{$user->id}}</td>
<td>{{$user->email}}</td>
<td>{{$user->password}}</td>
<td>
<!-- <img src="{{ url('storage/app/fileToUpload/'.$user->pic) }}" style="height:100; width:100" />; -->
<img src="{{ url('storage/app/fileToUpload')}}{{$user->pic}}" style="height:100; width:100" />
</td>
</tr>
@endforeach
<input type="hidden" value={{csrf_token()}} name=_token>
</table>
</body>
</html>
唯一的问题:
<img src="{{ url('storage/app/fileToUpload')}}{{$user->pic}}" style="height:100; width:100" />
解决方案
尝试:
<img src="{{ url('storage/app/fileToUpload/'.$user->pic)}}" style="height:100; width:100" />
推荐阅读
- typescript - `xit` 和 `it.only` 的 TsLint 规则
- php - 如何强制浏览器重新缓存图像
- sql - 在 SQL Server 中将字符串转换为位(32)替代?
- python - 在Python中使用户名不区分大小写的好方法是什么?(初级水平)
- flutter - 如何在 widgetTree 之外访问 rxdart-bloc 函数?
- keycloak - 如何在不使用角色映射 API 的情况下创建具有自定义领域角色的 keycloak 用户?
- angular - 为什么我的域不重定向到 https?
- reactjs - React app calls a request in a loop when you open a page
- shell - 如何使用vim脚本在函数中执行命令
- python - Python“新风格”多重继承结合多个 __init__ 参数