我使用的是laravel 5.2。我正在建立一个帖子系统,其中用户评论它通过点击给定的图像。
图片的路径被正确获取,但是没有显示在视图中。视图中也没有给出错误。
我的控制器:
public function createemoji($action,$statusId)
{
$path=('/images/'.$action.'.gif');
$request=new storage();
$request->comment=$path;
$request->user_id=Auth::user()->id;
$request->post_id=$statusId;
$request->save();
$storage=storage::where(function($query) use($statusId)
{
$query->where('post_id',$statusId)
;
})
->orderBy('created_at','desc')->get();
dd($storage);
return redirect()->back()->with('storage',$storage);
}
我的观点:
<a href="{{route('createemoji',['action'=>'6796','statusid'=>$post->id])}}" id="6796" class="btn btn-sm"><img id="z1" src="/images/6796.gif" name="one"/></a>
我试图显示的方式:
@foreach($storages as $storage)
@if($storages==$post->storage)
<div class="row">
<section class=" col-md-offset-3 col-md-5">
<h4 id="h45"></h4>
<img src="{{ $storage->comment }}">
</section>
</div>
@endif
@endforeach
尝试img-src的完整路径,如下:
<img id="z1" src="www.yourdomain.com/images/6796.gif" name="one"/>
更进一步,你可以使用浏览器的检查工具检查图像元素。例如chrome