title: How to update pdf file and image file in codeigniter
body: <p>I want to upload PDF file as well as image file with on one <code>do_upload</code> </p>
  
  <p>I want to upload two different files in two different directory by using <code>codeigniter</code>. I wrote the following code in my model. but it will upload only the first image.</p>
  
  <pre><code>        if($_POST){
          if($_FILES['productimage']['name']){
          $img = $_FILES['productimage']['name']; 
  
          $config['upload_path'] = './uploads/products/';
          $config['allowed_types'] = 'png|jpg|gif|bmp';
          $config['overwrite'] = TRUE;
  
          $this-&gt;load-&gt;library('upload',$config);
          if(!$this-&gt;upload-&gt;do_upload('productimage'))
          {
             $errors = array('error' =&gt; $this-&gt;upload-&gt;display_errors());
             $img="";
  
          }
          else
          {
              $data =$this-&gt;upload-&gt;data();
              $img=$data['file_name'];
          //print_r($img);die;
          }
          }else{
              $img=$this-&gt;input-&gt;post('image_old');
          }
    if($_FILES['productpdf']['name']){
      $img = $_FILES['productpdf']['name']; 
  
    $config['upload_path'] = './uploads/products/';
    $config['allowed_types'] = 'png|jpg|gif|bmp|pdf';
    $config['overwrite'] = TRUE;
  
    $this-&gt;load-&gt;library('upload',$config);
    if(!$this-&gt;upload-&gt;do_upload('productpdf'))
    {
       $errors = array('error' =&gt; $this-&gt;upload-&gt;display_errors());
       $pdf="";
  
    }
    else
    {
      $data =$this-&gt;upload-&gt;data();
      $pdf=$data['file_name'];
  
    }
    }else{
      $pdf=$this-&gt;input-&gt;post('pdf_old');
  
    }
  //  print_r($img);print_r($pdf);die;
           $title = $this-&gt;input-&gt;post('productname');
           $content = $this-&gt;input-&gt;post('description');            
           $status = $this-&gt;input-&gt;post('status');
           $this-&gt;db-&gt;where('product_id', $id);
           $this-&gt;db-&gt;update('products',array('product_name'=&gt;$title,'product_content'=&gt;$content,'product_image'=&gt;$img,'product_file'=&gt;$pdf,'product_status'=&gt;$status));
  
  
  
      $this-&gt;db-&gt;where('product_id',$id);
      $this-&gt;db-&gt;delete('products_filter');
  
      $filters= $_POST['filter'];      
    foreach ($filters as $value) 
    {
  $this-&gt;db-&gt;insert('products_filter',array('product_id' =&gt; $id,'products_search_id'=&gt;$value));
    }
   return ($this-&gt;db-&gt;affected_rows() != 1)? false:true;
  
   }else{
              redirect(base_url('admin/products/product-list/'.$redirectid));
       }
  </code></pre>
  
  <p>}</p>