diff --git a/src/Network/Request.php b/src/Network/Request.php index 577579d1fe6..85c28c7a639 100644 --- a/src/Network/Request.php +++ b/src/Network/Request.php @@ -1,7 +1,5 @@ $data) { if (!is_numeric($key)) { $this->_processFileData($post, '', $data, $key); @@ -417,7 +415,11 @@ protected function _processFileData(&$post, $path, $data, $field) { if (is_array($fields)) { $this->_processFileData($post, $newPath, $fields, $field); } else { - $newPath .= '.' . $field; + if (strpos($newPath, '.') === false) { + $newPath = $field . '.' . $key; + } else { + $newPath .= '.' . $field; + } $post = Hash::insert($post, $newPath, $fields); } } diff --git a/tests/TestCase/Network/RequestTest.php b/tests/TestCase/Network/RequestTest.php index a29dac9d84b..4842c775584 100644 --- a/tests/TestCase/Network/RequestTest.php +++ b/tests/TestCase/Network/RequestTest.php @@ -1,7 +1,5 @@ assertEquals($expected, $request->data); + } - $files = array( - 'name' => array('birth_cert' => 'born on.txt'), - 'type' => array('birth_cert' => 'application/octet-stream'), - 'tmp_name' => array('birth_cert' => '/private/var/tmp/phpbsUWfH'), - 'error' => array('birth_cert' => 0), - 'size' => array('birth_cert' => 123) - ); +/** + * Test processing a file input with no .'s in it. + * + * @return void + */ + public function testProcessFilesFlat() { + $files = [ + 'birth_cert' => [ + 'name' => 'born on.txt', + 'type' => 'application/octet-stream', + 'tmp_name' => '/private/var/tmp/phpbsUWfH', + 'error' => 0, + 'size' => 123, + ] + ]; $request = new Request(compact('files')); - $expected = array( - 'birth_cert' => array( + $expected = [ + 'birth_cert' => [ 'name' => 'born on.txt', 'type' => 'application/octet-stream', 'tmp_name' => '/private/var/tmp/phpbsUWfH', 'error' => 0, 'size' => 123 - ) - ); + ] + ]; $this->assertEquals($expected, $request->data); }