function _save($id) { $blog = new Blog_model($id); $config['upload_path'] = $this->config->item('base_dir') . 'uploads/images/Blog/'; $config['allowed_types'] = 'gif|jpg|png'; // $config['max_size'] = '100'; // $config['max_width'] = '1024'; // $config['max_height'] = '768'; $this->load->library('upload', $config); if (!$this->upload->do_upload()) { $error = array('error' => $this->upload->display_errors()); // $this->load->view('upload_form', $error); //echo "ERROR" . print_r($error, 1); } else { $uploaded = $this->upload->data(); $_POST['thumb'] = $uploaded['orig_name']; } $uid = $this->session->userdata('id'); $_POST['current_author'] = $uid > 0 ? $uid : 1; if ($id) { $blog->save($_POST); } else { $id = $blog->create($_POST); } return $id; }