angularjs restangular customPUT与Slim php restful框架

时间:2015-08-29 09:34:04

标签: slim restangular

我正在尝试使用SLIM php更新数据库。但传入的表单数据值显示为空白。我已成功发布(customPOST)值。

以下是代码:

AngularJs:

UpdateCategoryFormData:function(category,catId){
    formData=new FormData();
    angular.forEach(category, function (fieldData, field) {
    formData.append(field, fieldData);
  });
  return Restangular.one('category/update',catId)
    .withHttpConfig({transformRequest: angular.identity})
    .customPUT(formData, undefined, {}, {'Content-Type': undefined});           
}

SLIM php:

$app->put('/category/update/:catId',function($catId) use($app){
$data=$app->request->put();
print_r($data);
$catName=$app->request->put('catName');
$catParent=$app->request->put('catParent');

结果是:

array()
echo $catName;

我得到一个空白作为$ catName;

的值

以下是标题的副本:

Request Method:PUT
Status Code:200 OK
Response Headers
view source
Connection:Keep-Alive
Content-Length:10
Content-Type:text/html
Date:Fri, 28 Aug 2015 03:48:28 GMT
Keep-Alive:timeout=5, max=100
Server:Apache/2.4.9 (Win32) PHP/5.5.12
X-Powered-By:PHP/5.5.12
Request Headers
view source
Accept:application/json, text/plain, */*
Accept-Encoding:gzip, deflate, sdch
Accept-Language:en-US,en;q=0.8
Connection:keep-alive
Content-Length:249
Content-Type:multipart/form-data; boundary=----WebKitFormBoundary4gUX2gCt7zCICZNN

User-Agent:Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2489.0 Safari/537.36
Request Payload
------WebKitFormBoundary4gUX2gCt7zCICZNN
Content-Disposition: form-data; name="catName"

Some Category
------WebKitFormBoundary4gUX2gCt7zCICZNN
Content-Disposition: form-data; name="catParent"

45
------WebKitFormBoundary4gUX2gCt7zCICZNN--

有人可以帮忙吗?

0 个答案:

没有答案