diff --git a/src/Network/Request.php b/src/Network/Request.php index 477be75c04e..dcae835d510 100644 --- a/src/Network/Request.php +++ b/src/Network/Request.php @@ -460,17 +460,28 @@ protected static function _base() */ protected function _processFiles($post, $files) { - if (is_array($files)) { + if (!is_array($files)) { + return $post; + } + + $fileData = []; + foreach ($files as $key => $data) { foreach ($files as $key => $data) { if (isset($data['tmp_name']) && is_string($data['tmp_name'])) { - $post[$key] = $data; + $fileData[$key] = $data; } else { $keyData = isset($post[$key]) ? $post[$key] : []; - $post[$key] = $this->_processFileData($keyData, $data); + $fileData[$key] = $this->_processFileData($keyData, $data); } } } + // Make a flat map that can be inserted into $post for BC. + $fileMap = Hash::flatten($fileData); + foreach ($fileMap as $key => $file) { + $post = Hash::insert($post, $key, $file); + } + return $post; }