CodeIgniter Upload Image File with preview using Jquery Ajax

CodeIgniter Upload Image File with preview using Jquery Ajax

In this tutorial, We will tell you how to upload images with preview using Jquery Ajax in Codeigniter. upload images and preview images are the most important parts of the website.

The Codeigniter providing uploading file and resize file library. so let’s see below the following example for image upload using ajax in Codeigniter(file upload using ajax in Codeigniter).

Overview

Step 1: Download and install Codeigniter
Step 2: Create a Database in table
Step 3: Connect to Database
Step 4: Create Controller
Step 5: Create a Model
Step 6: Create The View

Step 1: Download and install Codeigniter
We are going to install Codeigniter 3, first, we will download a fresh Codeigniter 3 version and install it in our system. so you can follow below Link for Download CodeIgniter.

Step 2: Create a Database in table
In this step, we have to create a table in the database, so we will create a database using the below code.

Step 3: Connect to Database
Go to the config folder and open database.php file some changes in this file like hostname, database username, database password, and database name.

Step 4: Create Controller
In this step, we will create a Upload_image.php file in the “application/controller” directory and paste the below code in this controller.
application/controller/Upload_image.php

Step 5: Create a Model
In this step, we will create a Upload_model.php file in the “application/models” directory and paste the below code in this model.
application/models/Upload_model.php

Step 6: Create The View
Finally, we will create the image_upload.php file in the views directory. here in this file use below following code.

Please follow and like us: