'The POST method is not supported for this route. Supported methods: GET, HEAD, PUT, PATCH, DELETE. Laravel 8

hello i have a problem with uploading a form this is my form

@extends('layouts.app-admin')
@section('content')
    <div class="container">
        <div class="row">
            <div class="col">
                <h1>Subir Accesorio</h1>
                <div class="card">
                    <div class="card-body">
                        <form action="{{ 'admin.files.store' }}" method="POST" enctype="multipart/form-data">

                        @csrf

                        <div class="form-group">
                            <label for="nombre"
                                class="col-md-4 col-form-label text-md-end">{{ __('Nombre Producto') }}</label>
                            <input type="text" name="nombre">
                        </div>

                        <div class="form-group">
                            <label for="precio"
                                class="col-md-4 col-form-label text-md-end">{{ __('Precio Producto') }}</label>
                            <input type="number" name="precioUnitario">
                        </div>
                        <div class="form-group">
                            <label for="stock"
                                class="col-md-4 col-form-label text-md-end">{{ __('Stock Producto') }}</label>
                            <input type="number" name="stock">
                        </div>

                        <div class="form-group">
                            <label for="descripcion"
                                class="col-md-4 col-form-label text-md-end">{{ __('Descripcion Producto') }}</label>
                            <input type="text" name="descripcion">
                        </div>

                        <div class="form-group">
                            <label for="usuario"
                                class="col-md-4 col-form-label text-md-end">{{ __('Imagen Producto') }}</label>
                            <input type="file" name="imagen" id="">
                        </div>

                        <div class="form-group">
                            <button type="submit" class="btn btn-primary col-md-12 ">Subir Productos</button>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>
@endsection

my web.php is

Route::resource('/admin/files', FileController::class)->names('admin.files');

and controller

<?php

namespace App\Http\Controllers\Admin;

use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use App\File;

class FileController extends Controller
{
    /**
 * Display a listing of the resource.
 *
 * @return \Illuminate\Http\Response
 */
public function index()
{
    return view('admin.files.index');
}

/**
 * Show the form for creating a new resource.
 *
 * @return \Illuminate\Http\Response
 */
public function create()
{
    return view('admin.files.create');
}

/**
 * Store a newly created resource in storage.
 *
 * @param  \Illuminate\Http\Request  $request
 * @return \Illuminate\Http\Response
 */
public function store(Request $request)
{
    return $request->all();
}

/**
 * Display the specified resource.
 *
 * @param  int  $id
 * @return \Illuminate\Http\Response
 */
public function show($file)
{
    return view('admin.files.show');
}

/**
 * Show the form for editing the specified resource.
 *
 * @param  int  $id
 * @return \Illuminate\Http\Response
 */
public function edit($file)
{
    return view('admin.files.edit');
}

/**
 * Update the specified resource in storage.
 *
 * @param  \Illuminate\Http\Request  $request
 * @param  int  $id
 * @return \Illuminate\Http\Response
 */
public function update(Request $request, $file)
{
    //
}

/**
 * Remove the specified resource from storage.
 *
 * @param  int  $id
 * @return \Illuminate\Http\Response
 */
public function destroy($file)
{
    //
}
}

and if I use the r command r:l

GET|HEAD        admin ...................... admin.principal › Admin\PrincipalController@principal 
  GET|HEAD        admin/files ....................... admin.files.index › Admin\FileController@index 
  POST            admin/files ....................... admin.files.store › Admin\FileController@store 
  GET|HEAD        admin/files/create .............. admin.files.create › Admin\FileController@create 
  GET|HEAD        admin/files/{file} .................. admin.files.show › Admin\FileController@show 
  PUT|PATCH       admin/files/{file} .............. admin.files.update › Admin\FileController@update  
  DELETE          admin/files/{file} ............ admin.files.destroy › Admin\FileController@destroy  
  GET|HEAD        admin/files/{file}/edit ............. admin.files.edit › Admin\FileController@edit  

the problem is that the method POST is not supported but it is that in the route it uses POST and I don't know what to do I try several things but I can't find a solution and I don't advance my goal is to upload a product through a form



Solution 1:[1]

Forgot to add route function on action attribute

<form action="{{ route('admin.files.store') }}" method="POST" enctype="multipart/form-data">

Solution 2:[2]

I had a smillier error ..try to check the following

  1. the action name should be the same of route name :

action="{{ route('admin.files.store')}}

2)check that you are using get to return the view of form and then post when you send request

Solution 3:[3]

Have had a similar problem. This is what I did try running this command

php artisan route:clear

Solution 4:[4]

When working with resource controllers it is best practice to use the @method() helper INSIDE the respective views form to specify the the request method.

For example use the route list command to see what request method the endpoint accepts and then pass that parameter to the @method() function.

Example

@method(‘post’)

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Militaru
Solution 2 Alya Al Siyabi
Solution 3 Brian Mweu
Solution 4 IBeThieving