如何获取通过PUT方法传递的数据 [英] How to get data passed from PUT method

查看:69
本文介绍了如何获取通过PUT方法传递的数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为Laravel创建一个API.我使用PUT方法更新数据.

I am creating an API for Laravel. I use the PUT method for updating data.

我使用PUT方法与邮递员发送数据.在我的控制器中,我得到了一个空数组.如何访问传递的数据?

I send data with Postman using the PUT method. In my controller, I got an empty array. How to access the passed data?

在我的路线上,我有:

Route::put('vehicletypes/{id}','API\VehicletypeController@update');

在我的控制器中:

public function update(Request $request, $id){

print_r($request->all()); exit;

}

如何获取通过 PUT 方法传递的数据?

How to get the data passed in PUT method?

推荐答案

由于PHP对

You are getting empty response because PHP have some security restrictions against PUT. But Laravel have a workaround for this.
So, to solve this you have to send a POST request from Postman instead, with a POST param _method with value PUT. And that should work.

这篇关于如何获取通过PUT方法传递的数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆