[eluser]DannGrant[/eluser]
Hi guys,
Sorry to bother you all, i know this problem exists and i've looked through the threads and i'm still struggling to come up with a solution.
The error i'm getting is 'The filetype you are attempting to upload is not allowed.'
This is my code, and it's getting caught at the do_upload().
Here's my code :[
Code:
function create()
{
if($this->input->post('submit'))
{
$this->load->library('form_validation');
$this->form_validation->set_rules('first_name', 'First Name', 'required|trim');
$this->form_validation->set_rules('last_name', 'Last Name', 'required|trim');
$this->form_validation->set_rules('position', 'Position', 'required|trim');
$this->form_validation->set_rules('club_role', 'Club Role', 'required|trim');
$this->form_validation->set_rules('funny_moment', 'Funniest Cricketing Moment', 'required|trim');
$this->form_validation->set_rules('best_moment', 'Best Cricketing Moment', 'required|trim');
if($this->form_validation->run() == FALSE)
{
$data['main_content'] = 'players/create';
$this->load->view('inc/template', $data);
}
else
{
$config['upload_path'] = './uploads/players/';
$config['allowed_types'] = 'jpg|png';
$config['max_size'] = '2000';
$config['max_width'] = '1024';
$config['max_height'] = '768';
$config['remove_spaces'] = TRUE;
$this->load->library('upload', $config);
if(!$this->upload->do_upload())
{
$data['error'] = array('error' => $this->upload->display_errors());
$data['main_content'] = 'players/main';
$this->load->view('inc/template', $data);
}
else
{
$data = array('upload_data' => $this->upload->data());
$this->load->model('player_model');
$player = array(
'player_id' => $this->input->post('player_id'),
'first_name' => $this->input->post('first_name'),
'last_name' => $this->input->post('last_name'),
'position' => $this->input->post('position'),
'club_role' => $this->input->post('club_role'),
'funny_moment' => $this->input->post('funny_moment'),
'best_moment' => $this->input->post('best_moment'),
'image_url' => 'uploads/players/' . $this->upload->data('orig_name')
);
$query = $this->player_model->add($player);
redirect('players');
}
}
}
else
{
$data['main_content'] = 'players/create';
$this->load->view('inc/template', $data);
}
}