mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-31 17:16:18 +00:00
Dispatcher::parseParams() now works with file uploads that are not indexed by model. Fixes #9
This commit is contained in:
parent
1a86de5fe3
commit
adc198805f
2 changed files with 38 additions and 6 deletions
|
@ -303,14 +303,17 @@ class Dispatcher extends Object {
|
||||||
$params['url'] = $url;
|
$params['url'] = $url;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($_FILES as $name => $data) {
|
foreach ($_FILES as $name => $data) {
|
||||||
if ($name != 'data') {
|
if ($name != 'data') {
|
||||||
$params['form'][$name] = $data;
|
$params['form'][$name] = $data;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($_FILES['data'])) {
|
if (isset($_FILES['data'])) {
|
||||||
foreach ($_FILES['data'] as $key => $data) {
|
foreach ($_FILES['data'] as $key => $data) {
|
||||||
foreach ($data as $model => $fields) {
|
foreach ($data as $model => $fields) {
|
||||||
|
if (is_array($fields)) {
|
||||||
foreach ($fields as $field => $value) {
|
foreach ($fields as $field => $value) {
|
||||||
if (is_array($value)) {
|
if (is_array($value)) {
|
||||||
foreach ($value as $k => $v) {
|
foreach ($value as $k => $v) {
|
||||||
|
@ -320,6 +323,9 @@ class Dispatcher extends Object {
|
||||||
$params['data'][$model][$field][$key] = $value;
|
$params['data'][$model][$field][$key] = $value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
$params['data'][$model][$key] = $fields;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -883,6 +883,32 @@ class DispatcherTest extends CakeTestCase {
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
$this->assertEqual($result['data'], $expected);
|
$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
|
* testGetUrl method
|
||||||
|
|
Loading…
Add table
Reference in a new issue