public function post(){
if (empty($this->input->post('post_text')) && empty($_FILES['image']['name'])) {
redirect('posts');
}
$config['upload_path'] = './assets/images/postimages';
$config['allowed_types'] = 'gif|jpg|png|jpeg';
$config['max_size'] = '2048';
$this->load->library('upload', $config);
if (!empty($_FILES['image']['name'])) {
if ($this->upload->do_upload('image')) {
$post_image = $_FILES['image']['name'];
if ($this->Post_model->addPost($post_image)) {
array('upload_data' => $this->upload->data());
redirect('posts');
}else{
$this->session->set_flashdata('post_errors', 'Sorry something went wrong, Please try again');
redirect('posts');
}
}else{
//to diagnose i put else here and put redirect function
redirect('posts');
//so i try to upload an image it always come to else, if i remove else and submit the form it just go to the url and stops
like it go here http://localhost/friendmiiDemo/posts/post and stop
}
}else{
if ($this->Post_model->addPost()) {
redirect('posts');
}else{
$this->session->set_flashdata('post_errors', 'Sorry something went wrong, Please try again');
redirect('posts');
}
}
}