|
@@ -1351,9 +1351,8 @@ class PHP_CRUD_API {
|
1351
|
1351
|
return array($tableset,$collect,$select);
|
1352
|
1352
|
}
|
1353
|
1353
|
|
1354
|
|
- protected function retrieveInput($post) {
|
|
1354
|
+ protected function retrieveInputs($data) {
|
1355
|
1355
|
$input = (object)array();
|
1356
|
|
- $data = trim(file_get_contents($post));
|
1357
|
1356
|
if (strlen($data)>0) {
|
1358
|
1357
|
if ($data[0]=='{' || $data[0]=='[') {
|
1359
|
1358
|
$input = json_decode($data);
|
|
@@ -1491,9 +1490,9 @@ class PHP_CRUD_API {
|
1491
|
1490
|
if ($tenancy_function) $this->applyTenancyFunction($tenancy_function,$action,$database,$fields,$filters);
|
1492
|
1491
|
if ($column_authorizer) $this->applyColumnAuthorizer($column_authorizer,$action,$database,$fields);
|
1493
|
1492
|
|
1494
|
|
- if ($post) {
|
|
1493
|
+ if (strlen($post)) {
|
1495
|
1494
|
// input
|
1496
|
|
- $contexts = $this->retrieveInput($post);
|
|
1495
|
+ $contexts = $this->retrieveInputs($post);
|
1497
|
1496
|
$inputs = array();
|
1498
|
1497
|
foreach ($contexts as $context) {
|
1499
|
1498
|
$input = $this->filterInputByFields($context,$fields[$tables[0]]);
|
|
@@ -1697,6 +1696,22 @@ class PHP_CRUD_API {
|
1697
|
1696
|
$this->endOutput($callback);
|
1698
|
1697
|
}
|
1699
|
1698
|
|
|
1699
|
+ protected function retrievePostData() {
|
|
1700
|
+ if ($_FILES) {
|
|
1701
|
+ $files = array();
|
|
1702
|
+ foreach ($_FILES as $name => $file) {
|
|
1703
|
+ foreach ($file as $key => $value) {
|
|
1704
|
+ switch ($key) {
|
|
1705
|
+ case 'tmp_name': $files[$name] = base64_encode(file_get_contents($value)); break;
|
|
1706
|
+ default: $files[$name.'_'.$key] = $value;
|
|
1707
|
+ }
|
|
1708
|
+ }
|
|
1709
|
+ }
|
|
1710
|
+ return http_build_query(array_merge($files,$_POST));
|
|
1711
|
+ }
|
|
1712
|
+ return file_get_contents('php://input');
|
|
1713
|
+ }
|
|
1714
|
+
|
1700
|
1715
|
public function __construct($config) {
|
1701
|
1716
|
extract($config);
|
1702
|
1717
|
|
|
@@ -1742,7 +1757,7 @@ class PHP_CRUD_API {
|
1742
|
1757
|
$get = $_GET;
|
1743
|
1758
|
}
|
1744
|
1759
|
if (!$post) {
|
1745
|
|
- $post = 'php://input';
|
|
1760
|
+ $post = $this->retrievePostData();
|
1746
|
1761
|
}
|
1747
|
1762
|
|
1748
|
1763
|
// connect
|