3
我已经搜索了关于我的问题,我找到了一些解决方案,但这些都没有解决我的问题。我使用laravel 5.2,在这里我想上传一个图像,并在视图中显示它。我可以上传任何图像, 。但两件事情是:如何在Laravel刀片模板中显示上传的图像?
- 我看到,在数据库
profilePic
coloumn是null
。但图像 完全在我的公共/ 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的初学者。 在此先感谢。