skip to Main Content

I am using Laravel 10 and have the following route defined:

Route::post('bulkPromptsStore', [AppHttpControllersImageCategoryController::class, 'BulkInsertImagePrompts'])->name('bulkPromptsStore');

and in a blade file I call this in the normal way via a form

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

There follows a csrf field.

However when I press store I get the following error:

The POST method is not supported for route admin.imageCategory.bulkAdd/bulkPromptsStore. Supported methods: GET, HEAD.

I don’t get it as it is clearly marked as a post and I have double checked that there is not a duplicate route name.

2

Answers


  1. action="bulkPromptsStore" should be action="{{ route('bulkPromptsStore') }}" instead, if you wish to use the named route. I suspect your form is on a URL named admin.imageCategory.bulkAdd/ and thus your action is being treated like a relative URL within that pseudo-directory.

    Login or Signup to reply.
  2. <form action="{{ route('bulkPromptsStore') }}" method="post"
      enctype="multipart/form-data">
    

    Use it like this. It will work. Also don’t forget to use @csrf in form like this.

    <form action="{{ route('bulkPromptsStore') }}" method="post"
      enctype="multipart/form-data">
    @csrf
    
    
    ------ other codes ------
    
    </form>
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search