我使用 cakephp FormHelper 生成 html 表单代码。
echo $this->Form->create('newGallery.', array('type'=>'file'));
echo $this->Form->input('Photos',array(
'type' => 'file',
'label' => 'Photos (jpg,png,gif)',
'name' => 'upload[]',
'required',
'multiple'
));
echo $this->Form->end('Create');
但结果是
Array
(
[upload] => Array
(
[name] => Array
(
[0] => Pic1.jpg
[1] => Pic2.jpg
)
[type] => Array
(
[0] => image/jpeg
[1] => image/jpeg
)
[tmp_name] => Array
(
[0] => C:\wamp\tmp\phpB073.tmp
[1] => C:\wamp\tmp\phpB084.tmp
)
[error] => Array
(
[0] => 0
[1] => 0
)
[size] => Array
(
[0] => 216302
[1] => 107102
)
)
)
我需要对同一个文件的数据进行分组,以便我可以使用 foreach 循环来处理。这是我需要的结果
Array
(
[upload] => Array
(
[0] => Array
(
[name] => Pic1.jpg
[type] => image/jpeg
[tmp_name] => C:\wamp\tmp\phpB073.tmp
[error] => 0
[size] => 216302
)
[1] => Array
(
[name] => Pic2.jpg
[type] => image/jpeg
[tmp_name] => C:\wamp\tmp\phpB084.tmp
[error] => 0
[size] => 107102
)
)
)
确实感谢您的帮助。