简体   繁体   English

此路由不支持 GET 方法。 支持的方法:POST Laravel 8

[英]The GET method is not supported for this route. Supported methods: POST Laravel 8

home.blade.php file ''' home.blade.php 文件'''

@extends('layouts.app')

@section('content')
<div class="container">
    <div class="row justify-content-center">
        <div class="col-md-8">
            <div class="card">
                <div class="card-header">{{ __('Dashboard') }}</div>

                <div class="card-body">
                    @if (session('status'))
                        <div class="alert alert-success" role="alert">
                            {{ session('status') }}
                        </div>
                    @endif

                    {{ __('You are logged in!') }}
                </div>

                <div class="card-body">
                @csrf

                <form action="/upload" method="post"> 
                <input type="file" name="image">
                <input type="submit" name="upload">
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>
@endsection
'''

My routes '''我的路线'''

Route::post('/upload',function (){
   return('Halu');
});

I don't know where the error is help out as I am a beginner on laravel 8. The route is defined with the function and I don't know where the get or post goes wrong我不知道错误在哪里有帮助,因为我是 laravel 8 的初学者。路线是用函数定义的,我不知道 get 或 post 哪里出错了

Pass the url in action attribute.在 action 属性中传递 url。 and pass @csrf token inside the form.并在表单中传递@csrf令牌。

<form action="{{ url('/upload')}}" method="post">
 @csrf
</form>

you try to upload a file you have to set enctype="multipart/form-data" to your form it should look like this您尝试上传一个文件,您必须将enctype="multipart/form-data"为您的表单,它应该如下所示

<form action="{{ url('/upload')}}" method="post" enctype="multipart/form-data">
 @csrf
</form>

this may solve your issue这可能会解决您的问题

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Laravel: MethodNotAllowedHttpException: 此路由不支持 GET 方法。 支持的方法:POST - Laravel: MethodNotAllowedHttpException: The GET method is not supported for this route. Supported methods: POST Laravel - 此路由不支持 POST 方法。 支持的方法:GET、HEAD - Laravel - The POST method is not supported for this route. Supported methods: GET, HEAD 此路由不支持 GET 方法。 支持的方法:POST。 与 laravel - The GET method is not supported for this route. Supported methods: POST. with laravel Laravel 8:此路由不支持 GET 方法。 支持的方法:POST - Laravel 8: The GET method is not supported for this route. Supported methods: POST 此路由不支持 GET 方法。 支持的方法:POST。 在 laravel 8 - The GET method is not supported for this route. Supported methods: POST. in laravel 8 此路由不支持 POST 方法。 支持的方法:GET、HEAD (LARAVEL) - POST method is not supported for this route. Supported methods: GET, HEAD (LARAVEL) 此路由不支持 GET 方法。 支持的方法:POST。 拉拉维尔 8 - The GET method is not supported for this route. Supported methods: POST. laravel 8 Laravel此路由不支持GET方法。 支持的方法:POST - Laravel The GET method is not supported for this route. Supported methods: POST Laravel 6:此路由不支持 GET 方法。 支持的方法:POST 错误 - Laravel 6: The GET method is not supported for this route. Supported methods: POST Error 此路由不支持 POST 方法。 支持的方法:GET、HEAD In Laravel - The POST method is not supported for this route. Supported methods: GET, HEAD In Laravel
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM