HTML form PUT method [duplicate]

2019-01-23 00:52发布

This question already has an answer here:

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's GET. When I set method='POST' it's POST.
I don't know why method='PUT' doesn't work. I have tested on Chrome and Firefox.

2条回答
爱情/是我丢掉的垃圾
2楼-- · 2019-01-23 01:13

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.

查看更多
叛逆
3楼-- · 2019-01-23 01:27

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">
查看更多
登录 后发表回答