title: Upload image & video on codeigniter
body: <p>I have some issue when I insert image and video on database, I am using codeigniter for program.</p>
  <p>When I insert both a video and image, my code does not work, but if I upload only one of image/video it works fine.</p>
  <p>How can I solve this issue to insert video and image?</p>
  <p>My controller code:</p>
  <pre class="lang-php prettyprint-override"><code>    private function _do_upload()
      {
          $config['upload_path']          = './assets/img/sni';
          $config['allowed_types']        = 'gif|jpg|png';
          $config['max_size']             = 3000; //set max size allowed in Kilobyte
          $config['max_width']            = 1000; // set max width image allowed
          $config['max_height']           = 1000; // set max height allowed
          $config['file_name']            = round(microtime(true) * 1000); //just milisecond timestamp fot unique name
  
          $this-&gt;load-&gt;library('upload', $config);
  
          if (!$this-&gt;upload-&gt;do_upload('image')) //upload and validate
          {
              $data['inputerror'][] = 'image';
              $data['error_string'][] = 'Upload error: ' . $this-&gt;upload-&gt;display_errors('', ''); //show ajax error
              $data['status'] = FALSE;
              echo json_encode($data);
              exit();
          }
  
          return $this-&gt;upload-&gt;data('file_name');
      }
  
      private function _do_upload_video()
      {
          $config['upload_path']          = './assets/img/sni';
          $config['allowed_types']        = 'mp4';
          $config['max_size']             = 9000148; //set max size allowed in Kilobyte
  
          $config['file_name']            = uniqid(); //just milisecond timestamp fot unique name
  
          $this-&gt;load-&gt;library('upload', $config);
  
          if (!$this-&gt;upload-&gt;do_upload('video')) //upload and validate
          {
              $data['inputerror'][] = 'video';
              $data['error_string'][] = 'Upload error: ' . $this-&gt;upload-&gt;display_errors('', ''); //show ajax error
              $data['status'] = FALSE;
              echo json_encode($data);
              exit();
          }
          return $this-&gt;upload-&gt;data('file_name');
      }
  
      public function add_data()
      {
          $this-&gt;_validate();
  
          $data = array(
              'kode_process' =&gt; $this-&gt;input-&gt;post('kode'),
              'process_name' =&gt; $this-&gt;input-&gt;post('name'),
              'remark' =&gt; $this-&gt;input-&gt;post('remark'),
              'category' =&gt; $this-&gt;input-&gt;post('category'),
              'cycle_time' =&gt; $this-&gt;input-&gt;post('cycle'),
              'smv' =&gt; $this-&gt;input-&gt;post('smv'),
              'total' =&gt; $this-&gt;input-&gt;post('total'),
  
          );
  
          if (!empty($_FILES['image']['name'])) {
              $upload = $this-&gt;_do_upload();
              $data['image'] = $upload;
          }
          if (!empty($_FILES['video']['name'])) {
              $upload = $this-&gt;_do_upload_video();
              $data['video'] = $upload;
          }
  
  
          $this-&gt;Sni_model-&gt;save($data);
          echo json_encode(array(&quot;status&quot; =&gt; TRUE));
  </code></pre>
  <p>Screenshot:</p>
  <p><img src="https://i.stack.imgur.com/QUQVa.png" alt="enter image description here" /></p>