Upload file ajax codeigniter

Upload Files using Codeigniter and Ajax

Upload file ajax codeigniter

I think youll agree if I say this:

It is very difficult to create file upload with Codeigniter and AJAX Jquery.

The good news:

Well, it turns out, you can easily create file uploads with Codeigniter and AJAX Jquery. Right now!

In todays tutorial. You will learn everything you need to know about how to create upload files with Codeigniter and Ajax jquery.

(Step-by-Step)

Lets get started.

Step 1. Preparation

This is important!

If you missed this step, it means you missed the whole of this tutorial.

Good preparation will determine your success following this tutorial. The better your preparation, the more likely you will succeed in following this tutorial.

Do not skip this step, though it feels complex.

So, what do you need to prepare?

Heres the list:

1. Codeiginter

Codeigniter is the main php framework we will use in this tutorial. If you do not have it yet, please download it at the official website: www.codeigniter.com

2. Bootstrap

Bootstrap is a framework to beautify the user interface (UI). If you do not have it yet, please download it first at the official website: www.getbootstrap.com

3. Jquery

This is important!

Jquery is a javascript library that works to help simplify the writing of AJAX-based scripts.

If you do not have it yet, please download it at the official website: www.jquery.com

Ok, Lets continue!

Step 2. Database preparation

In this tutorial, I use mysql as Database Management System (DBMS).

If you also use mysql, you will love this tutorial.

But,

If you are using other DBMS like Oracle, SQL Server, or Maria DB.

No, Problem!

Provided you understand SQL (Structured Query Language) better.

Ok, Lets continue!

Please create a database, here I create a database with named upload_db.

If you create a database with the same name it will be better.

Please execute this query to create the database:

CREATE DATABASE upload_db;

That query will generate a database with named upload_db.

After that,

Create a table with name gallery with structure like this:

Upload file ajax codeigniter

To create a table structure like the picture above,

You could follow this query:

CREATE TABLE gallery(
id INT(11) PRIMARY KEY AUTO_INCREMENT,
title VARCHAR(100),
file_name VARCHAR(40)
)ENGINE=INNODB;

Step 3. Codeigniter Installation

Next,

Extract codeigniter that has been downloaded earlier to www folder (if you use wampserver) or htdocs (if you use XAMPP).

Because I use wampserver. So, I extract it to c:/wamp/www/

And then, rename codeigniter project to be ajax_upload.

CONTINUE READING []