cakephp 2使用数据上传多个文件

I am trying to create a multiple file upload using cakephp 2. so please help. i new to cakephp as you can see my controller and view coding is wokking for single image.

public function admin_add() {
    if ($this->request->is('post')) {
        $this->Portfolio->create();
        $error_message = $this->Portfolio->checkFileSize($this->request->data);
        if( $error_message === true ) {
            $this->request->data['Portfolio'] = $this->Common->processMedia($this->request->data['Portfolio']);
           //echo '<pre>'; print_r($this->request->data); echo '</pre>';
           // exit();

            if ($this->Portfolio->save($this->request->data)) {

                $this->Session->setFlash(__('The portfolio has been saved'), 'flash_success');

                $this->redirect(array('action' => 'index'));

            } else {

                $this->Session->setFlash(__('The portfolio could not be saved. Please, try again.'), 'flash_error');

            }

        } else {

            $this->Session->setFlash(__($error_message), 'flash_error');

        }

    }

    $talents = $this->Portfolio->Talent->find('list');


    $skills = $this->Portfolio->Skill->find('list', array(

        'order' => array('Skill.name ASC')

    ));

    $this->set(compact('talents', 'skills'));

} 

View -

<input type="file" name="data[Portfolio][media_url_file][]" class=" validate[] m-wrap large" id="PortfolioMediaUrlFile" multiple>

This My database Structure Database:- enter image description here

genrated Array- . using foreach could not enable to save this array in database .

Array
(
    [Portfolio] => Array
        (
            [talent_id] => 435
            [title] => asas
            [status] => Approved
            [type_of_media] => picture
            [file] => Array
                (
                    [0] => Array
                        (
                            [name] => wi-logo.png
                            [type] => image/png
                            [tmp_name] => /tmp/phpn8ne7a
                            [error] => 0
                            [size] => 17457
                        )

                    [1] => Array
                        (
                            [name] => unnamed.png
                            [type] => image/png
                            [tmp_name] => /tmp/phpPcqpQw
                            [error] => 0
                            [size] => 14362
                        )

                )

            [media_url] => Array
                (
                    [0] => Array
                        (
                            [name] => wi-logo.png
                            [type] => image/png
                            [tmp_name] => /tmp/phpn8ne7a
                            [error] => 0
                            [size] => 17457
                        )

                    [1] => Array
                        (
                            [name] => unnamed.png
                            [type] => image/png
                            [tmp_name] => /tmp/phpPcqpQw
                            [error] => 0
                            [size] => 14362
                        )

                )

        )

)

If it is working for a single upload then it can be extended to multiple. Why not creating multiple input fields? Each file has it own input. give each input a unique name and in the controller you can refer to the input in a loop

$this->request->data['Portfolio1']
$this->request->data['Portfolio2']
$this->request->data['Portfolio3']
...

I think I understand the problem now. You want save the requested data but your data contains arrays, which does not work. So you have to create an data array which matches your db structure. Here I do not understand why you have 'file' and 'mediaurl' which are containing the same data. But here my solution:

$this->Portfolio->create();
for($i = 0;$i < $this->request->data['Portfolio'][file];i++){
    $dataArray = [];
    //fill in your data which will be the same for each uploaded file
    $dataArray['talen_id'] = $this->request->data['Portfolio']['talen_id'];
    $dataArray['title'] = $this->request->data['Portfolio']['title'];
    $dataArray['status'] = $this->request->data['Portfolio']['status'];
    $dataArray['picture'] = $this->request->data['Portfolio']['picture'];
    //fill in your data which is different for each uploaded file
    $dataArray['media_url'] = $this->request->data['Portfolio']['media_url'][$i]['name'];
    $dataArray['file'] = $this->request->data['Portfolio']['file'][$i]['name'];
    //now you can save the data
    $this->Portfolio->save($dataArray);
}