Upload and Play Video using Codeigniter

This tutorial will show you how to upload a video and display or play the video using Codeigniter. CodeIgniter’s File Uploading Class permits files to be uploaded. You can set various preferences, restricting the type and size of the files.

Uploading a file involves the following general process:

An upload form is displayed, allowing a user to select a file and upload it.
When the form is submitted, the file is uploaded to the destination you specify.
Along the way, the file is validated to make sure it is allowed to be uploaded based on the preferences you set.
Once uploaded, the user will be shown a success message.


Netbeans 8.1
XAMPP in Windows
Codeigniter 3.0.6
Configure XAMPP and Netbeans

From Netbeans IDE go to Tools->Options. Click on PHP. Now on tab “General” browse the file for “PHP 5 Interpreter”. The php interpreter file generally placed inside the <physical drive in Windows OS>:xamppphpphp.exe

Configure Codeigniter and Netbeans

Create a new PHP project in Netbeans. Then remove the index.php file from the newly created project. Now copy the extracted files from Codeigniter 3.0.6 to the newly created project directory.

Directory Structure

A typical directory structure for the project would be as shown below. Here upload directory will contain the uploaded video file.
image upload resize codeigniter

Step 1. Now modify <root directory>/application/config/autoload.php file for auto-loading html, url, file and form

Step 2. Create a view file upload_video under <root directory>/application/views which will be used for uploading video file

Step 3. Create a Controller class  under <root directory>/application/controllers for handling client’s request and response

Step 4. Now modify <root directory>/application/config/routes.php file for pointing the default controller class

Step 5. Now if everything is fine run the application, you will see below output in the browser

codeigniter video

Step 6. Now browse and select a video file, the file will be uploaded to <root directory>/application/upload directory and the uploaded video will be displayed or played on browser

Video uploaded to directory

codeigniter video

Uploaded and displayed on to the browser

codeigniter video

Playing video on browser

codeigniter video

Sample videos can be found at http://www.sample-videos.com/

Thanks for reading.


Software Professional, I am passionate to work on web/enterprise application. For more information please go to about me. You can follow on Twitter. You can be a friend on Facebook or Google Plus or Linkedin

2 thoughts on “Upload and Play Video using Codeigniter

  1. Very nice tuto
    you should add
    at after ligne 60 to initialized your own configuration.

Leave a Reply

Your email address will not be published. Required fields are marked *

Time limit is exhausted. Please reload CAPTCHA.