[英]Laravel form submit showing MethodNotAllowedHttpException in RouteCollection.php line 218:
This is my route 这是我的路线
Route::resource('admin/reports', 'ReportController');
This is controller function 这是控制器功能
public function store(Request $request)
{
return "Thank you";
}
This is my html code 这是我的HTML代码
{!! Form::open([ 'url' => 'admin/reports/store', 'files' => true, 'enctype' => 'multipart/form-data', 'class' => 'dropzone', 'id' => 'reportfile' ]) !!}
{!! csrf_field() !!}
<div class="col-md-12">
<h3 style="text-align : center">Select File</h3>
</div>
<div class="col-md-12" style="text-align: center; padding: 10px">
<button type="submit" class="btn btn-primary">Upload Report</button>
</div>
{!! Form::close() !!}
When I submit the form, it show me MethodNotAllowedHttpException in RouteCollection.php line 218: 当我提交表单时,它会在RouteCollection.php第218行显示MethodNotAllowedHttpException:
Any help is much appreciated. 任何帮助深表感谢。 Thanks 谢谢
Your form action should just be admin/reports. 您的表单操作应该只是admin / reports。
Currently it will assume you are trying to post to the route admin/reports/{id}. 目前,它将假设您尝试发布到admin / reports / {id}路由。 That endpoint is used with GET, PUT and DELETE. 该端点与GET,PUT和DELETE一起使用。
Check the docs including a table giving you routes https://laravel.com/docs/5.1/controllers#restful-resource-controllers if I were you I'd use the route helper to generate your urls for you 检查文档,包括一个表格,给你路线https://laravel.com/docs/5.1/controllers#restful-resource-controllers如果我是你我会使用路线助手为你生成你的网址
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.