Skip to content

Instantly share code, notes, and snippets.

@aleckyann
Created July 9, 2018 01:25
Show Gist options
  • Save aleckyann/e879004d751c4bce856e418310326033 to your computer and use it in GitHub Desktop.
Save aleckyann/e879004d751c4bce856e418310326033 to your computer and use it in GitHub Desktop.
upload
/**
* use no form: enctype="multipart/form-data"
**/
public function insert_foto($equipamento)
{
$config['upload_path'] = FCPATH . 'public/application/equipamentos/fotos';
$config['allowed_types'] = 'jpg|png|jpeg|gif|tif';
$config['max_size'] = 1024 * 5;
$config['overwrite'] = TRUE;
$config['file_name'] = $equipamento['equipamento_id'];
$this->upload->initialize($config);
if($this->upload->do_upload('equipamento_foto')){
$caminho = base_url() . 'public/application/equipamentos/fotos/' . $this->upload->data()['file_name'];
$this->db->update('equipamentos', array('equipamento_foto' => $caminho), 'equipamento_id = ' . $equipamento['equipamento_id']);
} else {
pre($this->upload->display_errors());//error
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment