我真的需要帮助。我想允许用户多次上传单眉。
观点是这样的:
<?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>
,控制器是这样的:
/**
* 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 could not be 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'));
}
所以我想要实现的是,当用户点击浏览时,他可以选择多个图像,并选择此图片所属的类型。因此,当他点击时,将所有选择的上传照片和belonges提交给他刚刚选择的类型。那么如何只用一次提交就可以保存db中的所有图像路径?
感谢名单