public function upload_delete($id = '')
{
$this->load->helper('file');
if (!is_numeric($id)) {
redirect('admin/kb/articles/');
}
$id = (int) $id;
$this->db->select('attach_id, article_id, attach_file')->from('attachments')->where('attach_id', $id);
$query = $this->db->get();
if ($query->num_rows() > 0) {
$row = $query->row();
$article_id = $row->article_id;
unlink(ROOTPATH . 'uploads/' . $row->article_id . '/' . $row->attach_file);
$this->db->delete('attachments', array('attach_id' => $id));
redirect('admin/kb/articles/edit/' . $article_id . '/#attachments');
} else {
redirect('admin/kb/articles/');
}
}