How to upload Multiple Files and Images in CodeIgniter?

Today, We want to share with you multiple upload codeigniter.In this post we will show you Codeigniter – Upload Multiple File and Image Example, hear for How To Insert Multiple Image In Database Using Codeigniter? we will give you demo and example for implement.In this post, we will learn about How To Upload Multiple Images In Codeigniter? with an example.

Multiple files upload in Codeigniter

Step 1: Download Fresh Codeigniter 3

download fresh version of Codeigniter 3
download from here Free Download Codeigniter 3

Step 2: Add Route

application/config/routes.php


Step 3: Create Controller

application/controllers/ProfilePicUpload.php

load->helper('url'); 
   }
  
   /**
    * Manage index
    *
    * @return Response
   */
   public function index() { 
      $this->load->view('profileDpFormLoadData'); 
   } 
    
   /**
    * Manage storeProfileDP
    *
    * @return Response
   */
   public function storeProfileDP() { 
   
      $data = [];
   
      $count = count($_FILES['profiles']['name']);
    
      for($i=0;$i<$count;$i++){
    
        if(!empty($_FILES['profiles']['name'][$i])){
    
          $_FILES['file']['name'] = $_FILES['profiles']['name'][$i];
          $_FILES['file']['type'] = $_FILES['profiles']['type'][$i];
          $_FILES['file']['tmp_name'] = $_FILES['profiles']['tmp_name'][$i];
          $_FILES['file']['error'] = $_FILES['profiles']['error'][$i];
          $_FILES['file']['size'] = $_FILES['profiles']['size'][$i];
  
          $config['upload_path'] = 'uploads/'; 
          $config['allowed_types'] = 'jpg|jpeg|png|gif';
          $config['max_size'] = '5000';
          $config['file_name'] = $_FILES['profiles']['name'][$i];
   
          $this->load->library('upload',$config); 
    
          if($this->upload->do_upload('file')){
            $dpStoreImg = $this->upload->data();
            $filename = $dpStoreImg['file_name'];
   
            $data['listProfiles'][] = $filename;
          }
        }
   
      }
   
      $this->load->view('profileDpFormLoadData', $data); 
   }
  
} 
?>

Step 4: Create View

application/views/profileDpFormLoadData.php



  
   Codeigniter - Upload Multiple Files and Images Example - www.pakainfo.com
  

  
    
       
    


application/config/config.php

$config['base_url'] = 'http://localhost:8000/';

I hope you get an idea about Multiple Files and Images in CodeIgniter.
I would like to have feedback on my infinityknow.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.

Leave a Comment