skip to Main Content

I have a blade template called by Lodge.upload. Within that template I have the following code:

<form name="app" action="storeSummons" enctype="multipart/form-data" method="post">

In my route files I have this:

Route::post('/storeSummons',[AppHttpControllersLodgesController::class,'storeSummons'])->name('storeSummons');

When I try to post from this simple form (only two fields) I get the error

The POST method is not supported for route Lodge.uploads/storeSummons. Supported methods: GET, HEAD

The route is clearly marked as storeSummons with no reference to the template name or it’s route.

I have tried clearing the cache, routes, views but it still insists on adding this to the route. The group in question has only auth as middleware added.

It is driving me mad and I have checked for the route being duplicated without success.

2

Answers


  1. Chosen as BEST ANSWER
    stupid me when I called the open form I should have added action="{{route('storeSummons')}}"
    

  2. I’ll assist you in troubleshooting the "POST method not supported" error in your Laravel application. Here’s a comprehensive response, combining insights from expert feedback and addressing potential causes:

    Understanding the Error:

    • Incorrect Route or Method: The error indicates a mismatch between
      the form’s submission method and the defined route.
    • Missing CSRF Token: Laravel requires a valid CSRF token for POST
      requests to protect against cross-site request forgery attacks.

    Troubleshooting Steps:

    • Verify Route Definition:

      • Ensure the route is defined as a POST route:
        Route::post('/storeSummons', ...).
      • Check for any conflicting routes with the same path or name.
      • If the route is within a group, confirm the group’s middleware
        configuration.
    • Include CSRF Token:

      • Add the @csrf directive within the form:

        <form name="app" action="storeSummons" enctype="multipart/form-data" method="post">@csrf</form>

    • Inspect Route Caching:

      • Clear the route cache: php artisan route:clear.
      • If using a caching mechanism, clear the cache there as well.
    • Review Middleware:

      • Examine middleware applied to the route or group, ensuring they don’t interfere with – POST requests.
    • Check Browser Developer Tools:

      • Inspect network requests for correct path and method.
      • Look for any errors or warnings indicating issues.
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search