title: How to Upload the image and Video in two Different Folder using Codeigniter
body: <p>I am fresher in codeignite and I want to Upload the image and video into image and video folder. But image and video uploaded into the same folder. </p>
  
  <p>I tried so many times using if condition, but nothing is changed.</p>
  
  <p>Please help to solve this problem.</p>
  
  <p>Here is my code:-</p>
  
  <pre><code>&lt;?php
  
  class Upload extends CI_Controller {
  
      function __construct()
      {
          parent::__construct();
          $this-&gt;load-&gt;helper(array('form', 'url'));
      }
  
      function index()
      {
          $data['data'] = "";
          $data['content']=$this-&gt;load-&gt;view('cmsblock/cmsblock',$data,TRUE);
          $this-&gt;load-&gt;view('includes/main',$data);
      }
  
      function do_upload()
      {    
  
  
          foreach ($_FILES as $key =&gt; $value) {
  
              if (!empty($value['tmp_name'])) {
  
  
                  if($key == "file1") {
  
                      $config['upload_path'] = 'uploads';
                      $config['allowed_types'] = 'mp4|3gp|gif|jpg|png|jpeg|pdf';
                      $config['max_size']='';
                      $config['max_width']='200000000';
                      $config['max_height']='1000000000000';
                      $this-&gt;load-&gt;library('upload',$config);
                      if ( ! $this-&gt;upload-&gt;do_upload($key)) {
                      $error = array('error' =&gt; $this-&gt;upload-&gt;display_errors());
                      //failed display the errors
                      } else {
  
                          $data = array('upload_data' =&gt; $this-&gt;upload-&gt;data());
                          $this-&gt;load-&gt;view('cmsblock/success', $data);
  
                      }
                  }
                  if($key == "file2") {
  
                      $config11['upload_path'] = 'videos';
                      //$config11['upload_path'] = 'uploads';
                      $config11['allowed_types'] = 'mp4|3gp|gif|jpg|png|jpeg|pdf';
                      $config11['max_size']='';
                      $config11['max_width']='200000000';
                      $config11['max_height']='1000000000000';
                      $this-&gt;load-&gt;library('upload',$config11);
                      if ( ! $this-&gt;upload-&gt;do_upload($key)) {
                      $error = array('error' =&gt; $this-&gt;upload-&gt;display_errors());
                      //failed display the errors
                      } else {
  
                          $data = array('upload_data' =&gt; $this-&gt;upload-&gt;data());
                          $this-&gt;load-&gt;view('cmsblock/success', $data);
  
                      }
                  }               
  
  
  
              }
          }
      }
  } ?&gt;
  </code></pre>
  
  <p>Here is my HTML file code:</p>
  
  <pre><code>&lt;?php echo form_open_multipart('admin/upload/do_upload');?&gt;
  
  &lt;input type="file" name="file1" id="file_1" /&gt;
  &lt;input type="file" name="file2" id="file_2"/&gt;
  &lt;br/&gt;&lt;br/&gt;
  
  &lt;input type="submit" value="upload" /&gt;
  
  &lt;/form&gt;
  </code></pre>