Laravel方法不允许例外(Laravel method not allowed exception)

编程入门 行业动态 更新时间:2024-10-27 05:33:48
Laravel方法不允许例外(Laravel method not allowed exception)

我似乎无法找出为什么我的提交给我回到MethodNotAllowedException 。 缩短了......这是表格:

<form role="form" id="tryitForm" class="form-horizontal" enctype="multipart/form-data" method="POST" action="{{route('user.update', Auth::user()->id)}}"> <input type="submit" class="btn btn-primary" name="save" value="Update"/>

我的路线设置如下:

Route::resource('user', 'UserController');

I can't seem to find out why does my submit give me back the MethodNotAllowedException. Shortened...here is the form:

<form role="form" id="tryitForm" class="form-horizontal" enctype="multipart/form-data" method="POST" action="{{route('user.update', Auth::user()->id)}}"> <input type="submit" class="btn btn-primary" name="save" value="Update"/>

And I have route set up as:

Route::resource('user', 'UserController');

最满意答案

您需要在表单中添加PUT方法。

<input name="_method" value="PUT" type="hidden"> <input type="hidden" value="{{ csrf_token() }}" name="_token">

You need to add PUT method into your form.

<input name="_method" value="PUT" type="hidden"> <input type="hidden" value="{{ csrf_token() }}" name="_token">

更多推荐

本文发布于:2023-07-05 01:11:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1031294.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:不允许   方法   Laravel   exception   allowed

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!