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

Also Read This πŸ‘‰   Laravel 6 Get Last Inserted ID using Eloquent

Step 2: Add Route


defined('BASEPATH') OR exit('No direct script access allowed');

$route['default_controller'] = 'welcome';
$route['404_override'] = '';
$route['translate_uri_dashes'] = FALSE;
$route['image-upload'] = 'ProfilePicUpload';
$route['image-upload/post']['post'] = "ProfilePicUpload/storeProfileDP";

Step 3: Create Controller


class ProfilePicUpload extends CI_Controller {
    * Manage __construct
    * @return Response
   public function __construct() { 
    * Manage index
    * @return Response
   public function index() { 
    * Manage storeProfileDP
    * @return Response
   public function storeProfileDP() { 
      $data = [];
      $count = count($_FILES['profiles']['name']);
          $_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];
            $dpStoreImg = $this->upload->data();
            $filename = $dpStoreImg['file_name'];
            $data['listProfiles'][] = $filename;
      $this->load->view('profileDpFormLoadData', $data); 

Step 4: Create View


<!doctype html>
   <title>Codeigniter - Upload Multiple Files and Images Example -</title>
    <strong><?php if(isset($listProfiles)) echo "Good Luck Successfully uploaded ".count($listProfiles)." profiles"; ?></strong>
    <form method='post' action='/image-upload/post' enctype='multipart/form-data'>
      <input type='file' name='profiles[]' multiple=""> <br/><br/>
      <input type='submit' value='Upload' name='upload' />


$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 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.