How does Laravel handle PUT requests from browsers?

后端 未结 6 1397
Happy的楠姐
Happy的楠姐 2020-12-20 12:17

I know browsers only support POST and GET requests, and Laravel supports PUT requests using the following code:



        
6条回答
  •  庸人自扰
    2020-12-20 12:59

    It inserts a hidden field, and that field mentions it is a PUT or DELETE request

    See here:

    echo Form::open('user/profile', 'PUT');
    

    results in:

    
    

    Then it looks for _method when routing in the request.php core file (look for 'spoofing' in the code) - and if it detects it - will use that value to route to the correct restful controller.

    It is still using "POST" to achieve this. There is no ajax used.

提交回复
热议问题