php - Edit a register with a form upload field -
i have app create register file upload. ok, file upload , created register it's fine.
i want when user put file, update. if not, not update of field containing file path.
but, need edit register. when edditing, file upload show error:
error: sqlstate[42s22]: column not found: 1054 unknown column 'array' in 'field list' sql query: update societario.attorneys set nome = 'teste editar', empresa = '', filial = '', unidade = 'energia', alcada = 'até 10.000', validade = '123123111', arquivo = array societario.attorneys.id = '83'
my create controller:
if($this->request->is('post')){ $targetfolder = 'societario/app/webroot/uploads/'; // relative root $tempfile = $this->request->data['attorney']['arquivo']['tmp_name']; $targetpath = $_server['document_root'] . $targetfolder; $targetfile = rtrim($targetpath,'/') . '/' . $this->request->data['attorney']['arquivo']['name'];; move_uploaded_file($tempfile,$targetfile); $this->attorney->saveall($this->request->data, array('fieldlist' => array('nome','empresa','filial','unidade','validade', 'alcada', 'status'))); $this->attorney->updateall( array('arquivo' => "'".$this->request->data['attorney']['arquivo']['name'] ."'",), array('id' => $this->attorney->id)); my edit controller:
edit: modified edit controller. solution in answer follows.
$this->attorney->id = $id; $this->set('poderes',$this->attorney->power->find('list', array('fields' => 'resumo'))); if ($this->request->is('get')) { $this->request->data = $this->attorney->read(); } else { if ($this->attorney->save($this->request->data)) { $this->session->setflash('usuário editado com sucesso!', 'default', array('class' => 'flash_sucess')); $this->redirect(array('action' => 'usuarios')); } }
arquivo = array it thinks array field... if literally want "array" saved put in single quotes. otherwise think forgot $.
edit - thought i'd mention in update statement.
Comments
Post a Comment