Home  >  Q&A  >  body text

php - 请问下。。laravel 如何获取post提交的formdata数据

写请楚一点,我这里是API,第三方提交的post数据,

我并不知道form-data会传来什么数据。

所以我要的是获取所有通过POST form-data提交过来的数据。

正常来说$request->all拿到的是前台传来的所有数据,

但是第三方提交过来的,使用$request->all并不能直接拿到form-data数据,

获者说我还没有发现可以直接拿到form-data的方法

现在只能用原生的方法拿..

自己解决了,$request->all可以拿到第三方通过GET提交的数据,但是POST的拿不到,可以使用getcontent拿到。

迷茫迷茫2685 days ago1437

reply all(4)I'll reply

  • 曾经蜡笔没有小新

    曾经蜡笔没有小新2017-05-16 13:01:50

    I did it myself. None of the methods you mentioned can work. request->all obtains get. Post cannot be obtained by this method. You need to use getcount. I don’t know how you feel about those few points. It doesn’t matter. I took care of it myself.

    reply
    0
  • 给我你的怀抱

    给我你的怀抱2017-05-16 13:01:50

    can be accessed via Request 对象来获取。
    如获取表单全部数据, $request->all()
    获取表单中键名为name的字段,$request->get('name') .
    For detailed information, please refer to the official documentation.

    reply
    0
  • 阿神

    阿神2017-05-16 13:01:50

    I wrote a Demo on GitHub, you can take a look. https://github.com/MhcII/Form...

    $request->all() can still be retrieved. I just tested this code and it works.

    foreach ($request->all() as $key=>$param) {
        if (is_object($param)) {
            // 这里是 file
        } else {
            // 这里是 text
        }
    }

    reply
    0
  • 黄舟

    黄舟2017-05-16 13:01:50

    $request->all(); // 获取form表单中的所有字段值
    $request->input('name'); // 获取form表单中输入框name='name'的字段值

    reply
    0
  • Cancelreply