[eluser]luffy[/eluser]
This is my code below:
public function create_pic()
{
$this->load->library('upload', $config);
$config['upload_path'] = './';
$config['allowed_types'] = 'gif|jpg|png';
$config['max_size'] = '100';
$config['max_width'] = '1024';
$config['max_height'] = '768';
$this->upload->initialize($config);
//$this->form_validation->set_rules('userpic',"lang:form_pic",'callback_create_pic');
if ($this->form_validation->run() == TRUE)
{
//$this->posts->create_pic();
if ( ! $this->upload->do_upload('userpic')){
$this->validation->set_message('create_pic',$this->upload->display_errors());
return false;
} else {
return true;
}
$this->session->set_flashdata('message', lang('successfully_created'));
redirect('admin/posts/create_pic', 'refresh');
}
$data['categories'] = $this->posts->get_categories();
$this->_template['page'] = 'posts/create_pic';
$this->system_library->load($this->_template['page'], $data, TRUE);
}
It will return one empty page. But how to show the error message when empty file?