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
action="bulkPromptsStore"
should beaction="{{ route('bulkPromptsStore') }}"
instead, if you wish to use the named route. I suspect your form is on a URL namedadmin.imageCategory.bulkAdd/
and thus your action is being treated like a relative URL within that pseudo-directory.Use it like this. It will work. Also don’t forget to use
@csrf
in form like this.