diff --git a/cake/dispatcher.php b/cake/dispatcher.php index 6140efacf..ca147f305 100644 --- a/cake/dispatcher.php +++ b/cake/dispatcher.php @@ -303,22 +303,28 @@ class Dispatcher extends Object { $params['url'] = $url; } } + foreach ($_FILES as $name => $data) { if ($name != 'data') { $params['form'][$name] = $data; } } + if (isset($_FILES['data'])) { foreach ($_FILES['data'] as $key => $data) { foreach ($data as $model => $fields) { - foreach ($fields as $field => $value) { - if (is_array($value)) { - foreach ($value as $k => $v) { - $params['data'][$model][$field][$k][$key] = $v; + if (is_array($fields)) { + foreach ($fields as $field => $value) { + if (is_array($value)) { + foreach ($value as $k => $v) { + $params['data'][$model][$field][$k][$key] = $v; + } + } else { + $params['data'][$model][$field][$key] = $value; } - } else { - $params['data'][$model][$field][$key] = $value; } + } else { + $params['data'][$model][$key] = $fields; } } } diff --git a/cake/tests/cases/dispatcher.test.php b/cake/tests/cases/dispatcher.test.php index 725a1467f..613c8949a 100644 --- a/cake/tests/cases/dispatcher.test.php +++ b/cake/tests/cases/dispatcher.test.php @@ -883,6 +883,32 @@ class DispatcherTest extends CakeTestCase { ) ); $this->assertEqual($result['data'], $expected); + + + $_FILES = array( + 'data' => 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) + ) + ); + + $Dispatcher =& new Dispatcher(); + $result = $Dispatcher->parseParams('/'); + + $expected = array( + 'birth_cert' => array( + 'name' => 'born on.txt', + 'type' => 'application/octet-stream', + 'tmp_name' => '/private/var/tmp/phpbsUWfH', + 'error' => 0, + 'size' => 123 + ) + ); + + $this->assertEqual($result['data'], $expected); } /** * testGetUrl method