paste it in your controller and change the field and model names accroding to
公共功能添加(){
$this->set('status_tbl', $this->Player->Status->find('list'));
if ($this->request->is('post')) {
$this->Player->create();
if(!empty($this->request->data)){
if(!empty($this->request->data['Player']['image']['name'])){
$file = $this->request->data['Player']['image'];
$ext = substr(strtolower(strrchr($file['name'], '.')), 1);
$arr_ext = array('jpg', 'jpeg', 'gif');
if(in_array($ext, $arr_ext)){
$this->request->data['Player']['image'] = $file['name'];
move_uploaded_file($file['tmp_name'],'uploads/file'.$file['name']);
$this->Player->save($this->request->data);
}
}
if($this->Player->save($this->request->data)){
return $this->redirect(array('controller'=>'Players',"action"=>'index'));
}
}
}
}