【发布时间】:2016-09-11 06:09:29
【问题描述】:
我搜索了我的问题并找到了一些解决方案,但这些解决方案并不能解决我的问题。我使用的是 laravel 5.2,在这里我想上传一张图片并在视图中显示它。我可以上传任何图片,它可以工作好吧。但有两件事是:
- 我在数据库中看到
profilePic列是null。但是图像是 完美上传到我的 public/img 文件夹中。 - 我怎样才能在视图中显示它?
我的 ProfileController 的存储数据如下:
$file = array('profilePic' => Input::file('profilePic'));
$destinationPath = 'img/'; // upload path
$extension = Input::file('profilePic')->getClientOriginalExtension();
$fileName = rand(11111,99999).'.'.$extension; // renaming image
Input::file('profilePic')->move($destinationPath, $fileName);
Profile::create($profile);
我的个人资料刀片是这样的:
@foreach($profiles as $profile)
<tr>
<td> <img src='{{ asset($profile->profilePic) }}'> </td>
</tr>
@endforeach
我的代码中的问题在哪里?请帮助。我是 Laravel 的初学者。 提前致谢。
【问题讨论】:
标签: php image laravel laravel-5.2