Welcome Guest, Not a member yet? Register   Sign In
PUT requests not getting detected
#1

Routes.php

PHP Code:
$routes->put('admin/buku/change/(:num)''Admin\BookController::changeBook/$1'); 

Admin/BookController.php

PHP Code:
public function changeBook($id){
  dd("test"); 

the form that calls the request

PHP Code:
<form class="border" action="<?= base_url('admin/buku/change/' . $bookData['book_id']) ?>" method="POST"

the form submission gives a 404 Error, but when i change the route method to POST, the route does get detected. I can't think of any explanation. The other projects i have doesn't have this issue so it shouldn't be related to my php installation or something
Reply
#2

You set a PUT route, and send a request with POST method, and get 404.
You set a POST route, and send a request with POST method, and get the page.
It seems no problem.

If you want to get PUT route,
1) send a request with PUT method, or
2) use HTTP Method Spoofing:
https://codeigniter4.github.io/CodeIgnit...ofing.html
Reply
#3

the method spoofing solution worked. thanks!
Reply




Theme © iAndrew 2016 - Forum software by © MyBB