HTML form PUT method
40,933
Solution 1
Browsers only support POST
and GET
, if you need PUT
, you have to send the form via post/get and then do the proper PUT
request on server-side.
EDIT although, most implementations of XMLHttpRequest support PUT
and DELETE
.
Solution 2
PUT
is not recognized and is assimilated to GET
.
Most frameworks use a hidden input to obtain PUT
or DELETE
:
<input type="hidden" name="_method" value="PUT">
Related videos on Youtube
Author by
Dagang
Updated on July 09, 2022Comments
-
Dagang almost 2 years
Because the server side only accepts PUT method, I used
method='PUT'
in the HTML form. But the browser didn't use method PUT as expected, it'sGET
. When I setmethod='POST'
it'sPOST
.
I don't know whymethod='PUT'
doesn't work. I have tested on Chrome and Firefox.-
ghostJago over 12 yearstry looking at stackoverflow.com/questions/812711/how-do-you-do-an-http-put, this has some code examples.
-