[eluser]darrentaytay[/eluser]
You will need to do add a snippet along the lines of this to your controller. Basically, this only adds your image data to your array that you pass to the model if a new image has been presented.
Code:
if (!empty($_POST['userfile']['name']))
{
// call the upload function
// if the upload function succeeds
// pass the image information to the model
if ($this->upload->do_upload())
{
$content['imagename'] => $file_info['file_name'];
$content['thumbname'] => $file_info['raw_name'].'_thumb'.$file_info['file_ext'];
}
}
Now we can check if there is a new image in the model by simply testing if the imagename & thumbname keys are passed through.
MODEL:
Code:
function updateSale($id, $content) {
$this ->db->where('id', $id);
$update = $this->db->get('sales');
$row = $update->row_array();
if($update->num_rows() > 0) {
if (isset($content['imagename']) && isset($content['thumbname']))
{
#lets delete the image
unlink("/includes/uploads/gallery/".$row['imagename']);
#lets delete the thumb.
unlink("/includes/uploads/gallery/thumbs/".$row['thumbname']);
}
$this->db->update('sales', $content);
} # End IF
} #