Hi all,
I want to make an new function for my website, but if i copy the script upload image from settings and copy that into an other script (upload section) this dont work, it wont upload the image to the server.
Who can help me?
```
public function form_portfolio($id = NULL)
{
if ($this->input->post('btn_cancel')) {
redirect('portfolio/index');
}
// Set validation rule based on is_update
if ($this->input->post('is_update') == 0 && $this->input->post('title') != '')
{
$check = $this->db->get_where('portfolio', array('title' => $this->input->post('title')))->result();
if (!empty($check))
{
$this->session->set_flashdata('alert_error', lang('portfolio_already_exists'));
redirect('portfolio/form_portfolio');
}
}
if ($this->mdl_portfolio->run_validation()) {
$id = $this->mdl_portfolio->save($id);
redirect('portfolio/view_portfolio/' . $id);
}
if ($id and !$this->input->post('btn_submit'))
{
if (!$this->mdl_portfolio->prep_form($id))
{
show_404();
}
/* Thumb image upload */
$upload_config = array(
'upload_path' => './uploads/',
'allowed_types' => 'gif|jpg|png|svg',
'max_size' => '9999',
'max_width' => '9999',
'max_height' => '9999'
);
if ($_FILES['thumb_img']['name']) {
$this->load->library('upload', $upload_config);
if (!$this->upload->do_upload('thumb_img')) {
$this->session->set_flashdata('alert_error', $this->upload->display_errors());
redirect('portfolio/form_portfolio');
}
$upload_data = $this->upload->data();
$this->mdl_settings->save('thumb_img', $upload_data['file_name']);
}
$this->mdl_portfolio->set_form_value('is_update', true);
}
$this->layout->buffer('content', 'portfolio/form_portfolio');
$this->layout->render();
}
```
View:
<input type="file" name="thumb_img" id="thumb_img" size="40" class="input-sm form-control"/>