[英]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.