I am trying to upload image using the code igniter. But it is giving me the following error

> 
> You did not select a file to upload
> 
> 
> 

I have tried, many different sources, but still getting the error.

The PHP Code is below:

```
public function save_post()
{
    $image_path = './uploads/';
    $config['upload_path'] = $image_path;
    $config['allowed_types'] = 'gif|jpg|png|jpeg';
    // $config['max_size']      = 5000;
    // $config['max_width']     = 1024;
    // $config['max_height']    = 1024;

    $this->load->library('upload', $config);
    $this->upload->initialize($config);

    if (!$this->upload->do_upload('postimage')) {
        $error = array('error' => $this->upload->display_errors());
        print_r($error);die;
        $this->add_post($error);
    } else {
        $data = array('upload_data' => $this->upload->data());
        $this->add_post($data);
    }
    die;
    $data = array(
        'page_title' => $this->input->post('ptitle'),
        'page_slug' => $this->input->post('pslug'),
        'page_body' => $this->input->post('pbody'),
        'page_keyword' => $this->input->post('pkeywords'),
        'page_description' => $this->input->post('pdesc'),
        'page_image' => $this->input->post('postimage'),
    );

    $this->admin_model->save_post($data);
    redirect(base_url() . 'admin/all_posts');
}

```

**My View is below**

```
 <form method="post" action="<?php echo base_url(); ?>admin/save_post"  enctype ="multipart/form-data ">
    <div class="form-group">
        <label for="postimage">Feature Image</label>
        <input type="file" class="form-control" id="postimage" name="postimage" required> 
    </div>
    <div> <?php if(isset($error)) echo $error; ?></div>
    <div class="form-group">
        <input type="submit" value="publish" name="submit" id="post-submit" class="btn btn-success waves-effect waves-light">
    </div>
</form>

```