title: How to upload data to database using codeigniter
body: <p>I want to upload the image to database using codeigniter. It saved to database but the image didn't send to the folder path i've set and only the image_path are saved to the database. Can you tell me what to do or anything I did wrong? Here's my code:</p>
  
  <p><strong>* Controller *</strong></p>
  
  <pre><code>
  function saveEvent(){
  
          $config = [
              'upload_path' =&gt; './assets/img',
              'allowed_types' =&gt; 'gif|png|jpg|jppeg'
          ];
  
          $this-&gt;load-&gt;library('upload', $config);
          $this-&gt;form_validation-&gt;set_error_delimiters();
          $this-&gt;upload-&gt;do_upload();
          // var_dump('asd'. $this-&gt;upload-&gt;do_upload());
          // if($this-&gt;upload-&gt;do_upload()){
              $datas = $this-&gt;input-&gt;post('eventimage');
              $info = $this-&gt;upload-&gt;data();
              $image_path = "./assets/img/".$info['raw_name'].$info['file_ext'];
              $data['cal_events_image'] = $image_path;
              $data['cal_events_name'] = $this-&gt;input-&gt;post('eventname');
              unset($data['submit']);
              $this-&gt;load-&gt;model('CalendarModel');
              if($this-&gt;CalendarModel-&gt;eventinsertdata($data)){
                  echo "success";
              }else{
                  echo " fail";
              }
  
  </code></pre>
  
  <p><strong>* View *</strong></p>
  
  <pre><code>
  &lt;form action="&lt;?php echo base_url('index.php/CalendarController/saveEvent');?&gt;" enctype="multipart/form-data" method="post" accept-charset="utf-8"&gt;
                  &lt;table class="table"&gt;
                      &lt;tr&gt;
                          &lt;td&gt;Event Type&lt;/td&gt;
                          &lt;td&gt;&lt;input type="text" name="eventname"&gt;&lt;/td&gt; 
                      &lt;/tr&gt;
                      &lt;tr&gt;
                          &lt;td&gt;Image&lt;/td&gt;
                          &lt;td&gt;&lt;input type="file" name="eventimage"&gt;&lt;/td&gt;
                      &lt;/tr&gt;
                      &lt;tr&gt;
                          &lt;td colspan="2"&gt;&lt;input type="submit" name="submitevent" value="Add Event" class="btn btn-success"&gt;&lt;/td&gt;
                      &lt;/tr&gt;
                  &lt;/table&gt;
              &lt;/form&gt;
  
  </code></pre>
  
  <p><strong>* Model *</strong></p>
  
  <pre><code>function eventinsertdata($data){
  return $this-&gt;db-&gt;insert('table', $data);
       return $this-&gt;db-&gt;insert('dev_adkt_events_type', $data);
          echo 'hahay';
  
      }
  
  </code></pre>
  
  <p>Thank you guys in advance. Hope you could help me with this.</p>