Laravel验证封面图像必须是图像问题

时间:2019-11-21 17:16:14

标签: laravel laravel-blade

我的代码收到了此错误消息。我不知道为什么它向我显示了此消息
刀片模板文件:

    <div class="well" style="font-family:arial;">
        <div class="well-body">
            <form class="POST" action="/admin-panel/shows/store" enctype="multipart/form-data">
            @csrf
            <table class="table table-striped">
                <tr>
                    <th>Show Name</th>
                    <th>
                    <div class="form-group">
                        <input type="text" class="form-control" name="name" placeholder="e.g, Avengers"/>
                    </div>
                    </th>
                </tr>
                <tr>
                    <th>Cover Image</th>
                    <th>
                        <div class="form-group">
                            @csrf
                            <input id="cover_image" type="file" name="cover_image">
                        </div>
                    </th>
                </tr>
            </table>
            <button type="submit" class="btn btn-primary pull-center">Submit</button>
            </form>
        </div>
    </div>

控制器文件:

public function store(Request $request)
{
    $this->validate($request,[
        'name' => 'required | max:140',
        'plot' => 'required',
        'cover_image' => 'image | required | max:1999'

    ]);
    -----Rest of the code ---
}

我还想补充一点,一个类似的用于后期创建的东西很好用。我可以用它们区分这两个代码。他们看起来一样。可以写action =“ / admin-panel / shows / store”这会有问题吗?

dd($ request-> input('cover_image')ss: enter image description here

dd($ request-> file('cover_image'))ss: enter image description here

更新:我没有正确进行路由。

0 个答案:

没有答案