我正在努力显示帖子,当我将数据与图像一起发布时,我的数据存储在DB中(图像也存储在目标文件夹中),但未显示在浏览器中,这是页面(索引)的代码。我试图在其中显示帖子的blade.php):
python -m compileall ./ #combines all programs under current directory
这是后期控制者
@extends('layouts.app')
@section('content')
<form method="POST" action="{{url('posts')}}" enctype="multipart/form-data">
<!--@if(session('message'))
{{session('messgae')}}
@endif-->
@if(count($errors) > 0)
<ul>
@foreach($errors->all() as $error)
<li>{{$error}}</li>
@endforeach
</ul>
@endif
{{csrf_field()}}
Name:- <input type="text" name="title" value="{{old('title')}}">
Text:- <textarea name="body">value="{{old('body')}"></textarea>
Upload File:- <input type="file" name="thumbnail" value="{{old('thumbnail')}}">
<input type="submit" value="submit">
</form>
@endsection
答案 0 :(得分:1)
我发现您的代码有误
@foreach($posts as post)
使用
@foreach($posts as $post)