Laravel5如何从HTTP PUT请求获取数据?

时间:2016-03-04 09:18:08

标签: php laravel laravel-5

我有HTTP PUT API,但无法从请求中检索。 Input :: all()返回空。你能分享怎么做吗?我确认$ request有form-data。

public function update(Request $request, $id)
{
    Log::info(Input::all()); // empty
    Log::info($id); // 1001
    Log::info($request);
}

$request -> 

local.INFO: PUT /v1/shops/1001 HTTP/1.1
.
.
.
------WebKitFormBoundary2B26VoCplFAB8W36
Content-Disposition: form-data; name="item_id"

9001
------WebKitFormBoundary2B26VoCplFAB8W36
Content-Disposition: form-data; name="name"

tokyo

Route.php

<?php
Route::resource('v1/shops', 'ShopController');
?>

详细

$request -> 
local.INFO: PUT /v1/shops/1001 HTTP/1.1
Accept:          */*
Accept-Encoding: gzip, deflate, sdch
Accept-Language: ja,en;q=0.8,en-US;q=0.6
Cache-Control:   no-cache
Connection:      keep-alive
Content-Length:  332
Content-Type:    multipart/form-data; boundary=----WebKitFormBoundaryAchDYDABHI1GDUeu
Cookie:          XXXXXXXXXXXXXX
Host:            XXXXXXXXXXXXXX
Origin:          chrome-extension://aicmkgpgakddgnaphhhpliifpcfhicfo
Postman-Token:   434976e3-3476-3dcd-3689-7048d523dd20
User-Agent:      Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/48.0.2564.116 Safari/537.36

------WebKitFormBoundary2B26VoCplFAB8W36
Content-Disposition: form-data; name="item_id"

9001
------WebKitFormBoundary2B26VoCplFAB8W36
Content-Disposition: form-data; name="name"

tokyo

1 个答案:

答案 0 :(得分:0)

我找到了。我应该选择“x-xxx-form-urlencoded”。不是“形式数据”

enter image description here

我有这个表单数据,可以通过Input :: all()

检索
user_id=1&address=2&tag=3  

这个问题是一个线索。 https://github.com/postmanlabs/postman-app-support/issues/8