Logo

Office Address

123/A, Miranda City Likaoli
Prikano, Dope

Phone Number

+0989 7876 9865 9

+(090) 8765 86543 85

Email Address

info@example.com

example.mail@hum.com

CodeIgniter upload multiple images using drag and drop using dropzone

CodeIgniter upload multiple images using drag and drop using dropzone

In this example we are going to explain how to upload mulitple images using dropzone library in Codeigniter. Simple drag and drop image on the webpage. dropzone jQuery plugin, you can easily upload images on the server. if you have any requirment of uploading builk images dropzone is the best option. Dropzone has a preview and remove option where you can add, view and remove option. 

Dropzone provides the different type of validation rules like max file upload, upload specific type of file like you can set the validation rule to take only jpeg extension. As a Codeigniter Development Company india we have used Dropzone in many of our web based application development company in Coimbatore

Follow below Steps to upload multiple images using dropzone

Step 1: Download Codeigniter latest Version


In this first step, Download Codeigniter latest Version to start with scratch. 

Step 2: Add Routes

In this step, I will setup two routes in route file to handle the request to upload file on the server.

Routes file Path - application/config/routes.php

<?php
defined('BASEPATH') OR exit('No direct script access allowed');
$route['default_controller'] = 'welcome';
$route['404_override'] = '';
$route['translate_uri_dashes'] = FALSE;
$route['dropzone-upload-image'] = 'ImageController';
$route['dropzone-upload-image/post']['post'] = 'ImageController/uploadImage';
?>

Step 3: Create Controller

In this step, create a controller "ImageController.php".

Controller file Path - application/controllers/.

<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class ImageController extends CI_Controller {
    public function index()
    {
        $this->load->view('fileupload');
    }

    public function uploadImage()
    {
        $config['upload_path']   = './uploads/'; 
        $config['allowed_types'] = 'gif|jpg|png'; 
        $config['max_size']      = 1024;

          $this->load->library('upload', $config);
        $this->upload->do_upload('file');

        print_r('Image Uploaded Successfully.');
        exit;
    }
} ?>

Step 4: Create View Files "fileupload.php"

In this step, create a view file "fileupload.php" to render the HTML form to upload image.

View file Path application/views/"fileupload.php"

<!DOCTYPE html>
<html>
<head>
    <title>Codeigniter - Upload multiple images using dropzone.js</title>
    <script src="https://code.jquery.com/jquery-3.3.1.min.js"></script>
    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css">
    <link href="https://cdnjs.cloudflare.com/ajax/libs/dropzone/4.0.1/min/dropzone.min.css" rel="stylesheet">
    <script src="https://cdnjs.cloudflare.com/ajax/libs/dropzone/4.2.0/min/dropzone.min.js"></script>
</head>
<body>
<div class="container">
    <div class="row">
        <div class="col-md-12">
            <form a ction="dropzone-upload-image/post" enctype="multipart/form-data" class="dropzone" id="image-upload" method="POST">
                <div>
                    <center><h3>Click here to upload multiple image</h3></center>
                </div>
            </form>
        </div>
    </div>
</div>
<script type="text/javascript">
    Dropzone.options.imageUpload = {
        maxFilesize:1,
        acceptedFiles: ".jpeg,.jpg,.png,.gif"
    };
</script>
</body>
</html>

Tags

  • CodeIgniter upload multiple file different directory

  • Multiple upload Dropzone CodeIgniter

  • Drag and drop multiple file upload in PHP

  • How to upload 2 separate images in CodeIgniter
  • How to upload two different files in CodeIgniter
  • Multiple image upload in CodeIgniter with database demo

  • CodeIgniter multiple file upload (array)

  • Drag and drop multiple image upload in PHP

  • Dropzone PHP multiple files upload

Related Posts

Upload CSV files and import to Database using Laravel PHP

Upload CSV files and import to Database using Laravel PHP

In this article, we are how to upload CSV file from a system and import in the database using Laravel. There are countless bundles accessible in Laravel to import dominant documents in the data set

Read More
Outsource ECommerce Development Company

Outsource ECommerce Development Company

In today’s competitive digital landscape, having a strong online presence is vital for businesses of all sizes. ECommerce websites are the backbone of modern retail, providing companies with a p

Read More
P

PHP Code Check time difference is between two time slots

We are going to explain how to get the time difference between timeslots. below are the simple example given to get the time difference between the two given slots. As you can see we have used the inb

Read More