Insert multiple row in one submit in cakephp -
i need on one. want allow user multiple upload single brows.
view this:
<?php echo $this->form->create('typologypicture', array('type'=>'file')); ?> <legend><?php echo __('add picture'); ?></legend> <?php echo $this->form->input('id'); echo $this->form->input('typology_id'); echo $this->form->input('pic_path', array('label'=>'picture','type'=>'file','multiple'=>'multiple')); ?> <?php echo $this->form->end(__('submit')); ?> </div>
and controller this:
/** * add method * * @return void */ public function add() { if ($this->request->is('post')) { $this->typologypicture->create(); if ($this->typologypicture->save($this->request->data)) { $this->session->setflash(__('the typology picture has been saved.')); return $this->redirect(array('action' => 'index')); } else { $this->session->setflash(__('the typology picture not saved. please, try again.')); } } if ( authcomponent::user('role')==='admin' ||authcomponent::user('role')==='superadmin' ){ $typologies = $this->typologypicture->itemtypologypicture->find('list'); } else { $typologies = $this->typologypicture->itemtypologypicture->find('list', array('conditions' => array('itemtypologypicture.user_id' => authcomponent::user('id')))); } $this->set(compact('typologies')); }
so want achieve when user click browse, can select multiple images, , selects typology pic belonges to. when clicks submit phottos selected uploads , belonges typology selected. how can save images paths in db 1 submit??
thanx
this pretty explained in section of cakephp book on saving data, particularly part on saveall()
Comments
Post a Comment