[eluser]amipaxs[/eluser]
Hi,
I have a form for categories data and 1 category image, when i want to edit a field, i want to give the user the chance to change the first uploaded image, when the user doesn't want to upload a new image i have two posibilities, saves data with image info and no save image info at all..
Code:
MODEL
if(!empty($_POST['cat_img'])){ // this check isn't working !!! how can i check whether or not an image has been sent ???
if(!$this->upload->do_upload('cat_img')){
return $this->session->set_flashdata('mensaje', utf8_decode($this->upload->display_errors()));
}
$image = $this->upload->data();
$data= array(
'nombre' => db_clean($_POST['fnom_cat'],255),
'desc_corta' => db_clean(utf8_encode($_POST['fdesc1']),255),
'desc_larga' => db_clean(utf8_encode($_POST['fdesc2']),1000),
'ruta_img' => "/uploads/".$image['file_name'],
'nombre_img' => $image['raw_name'], //nombre sin extension
'tipo_img' => $image['image_type'],
'estado' => $_POST['festado'],
'id_padre' => $_POST['id_padre']
);
}else{
$data= array(
'nombre' => db_clean($_POST['fnom_cat'],255),
'desc_corta' => db_clean(utf8_encode($_POST['fdesc1']),255),
'desc_larga' => db_clean(utf8_encode($_POST['fdesc2']),1000),
'estado' => $_POST['festado'],
'id_padre' => $_POST['id_padre']
);
}
$this->db->where('id', $_POST['id']);
return $this->db->update('categorias', $data);
}
I can't check whether the field 'cat_img' is empty or not. any ideas??
thanks in advance