I'm stuck on a problem with updating image. I've created image upload which works fine but I also want it to be updated. When I add a need image it updates correctly but I if don't want to change the image and leave it as it is, then my current image can't be retrieve.
Please help me
Here is my code:
my model update
function updateDatasale($id){
$data=array(
'mayor_permit_attachment'=>$this->mayors_attachment()
);
$this->db->where('id',$id);
$this->db->update('tickets',$data);
}
function mayors_attachment(){
$pic=array(
'upload_path'=>'./uploads/',
'allowed_types'=>'gif|jpg|png',
'max_size'=>4000,
'max_width'=>10024,
'max_height'=>10024,
);
$this->load->library("upload",$pic);
if($this->upload->do_upload('mayors_attachment')){
$fb=$this->upload->data();
$fd=$fb['file_name'];
return $fd;
}
else{
$data = "null";
return $data;
}
}
controller
public function updatesales($id){
$this->TicketReply_model->updateDatasale($id);
redirect("accepttask");
}
views
<tr>
<td>
<span class="text-danger text-bold">
<label>Mayors Permit:</label>
<input type="file" name="mayors_attachment" >
</td>
</tr>