PHP Professional এবং Zend Certified PHP Engineer (ZCPE ) Course এ সীমিত সংখ্যক আসন বাকি আছে। আগ্রহীদেরকে অতিসত্বর মাসুদ আলম স্যার এর সাথে যোগাযোগ করার জন্য অনুরোধ করা যাচ্ছে। স্যার এর মোবাইল নম্বর : ০১৭২২ ৮১ ৭৫ ৯১

Making File Upload System Using CodeIgniter Framework

In This Tutorial I will discuss How to Make File Upload System Using PHP CodeIgniter Framework.

At Essentially in CodeIgniter to do upload file we have given her class to help us developers, and this time we will discuss the class.

Let’s discussed step by step below:

  1. Create upload_form.php file and place it in the application / views and type the following script:


<title>CodeIgniter Upload Form </title>



<?php echo $error;?>

<?php echo form_open_multipart('fileupload/do_upload');?>

<input type="file" name="userfile" size="20" />

<br /><br />

<input type="submit" value="upload" />




2.       Then create upload_success.php file and place it in application / views and contents of the script as follows:



<title>File Upload Success </title>



<h3>Your file was uploaded successfully </h3>


<?php foreach ($upload_data as $item => $value):?>

<li><?php echo $item;?>: <?php echo $value;?></li>

<?php endforeach; ?>



<?php echo anchor('upload', 'Other files uploaded!'); ?>




3.       If you’ve made the files for views, now we create a file for the controllers. Create fileupload.php and place in application / controllers / with the following script:


class Upload extends CI_Controller {

function __construct()



$this->load->helper(array('form', 'url'));


function index()


$this->load->view('upload_form', array('error' => ' ' ));


function do_upload()


$config['upload_path'] = './uploads/';

$config['allowed_types'] = 'gif|jpg|png';

$config['max_size']    = '100000';

$config['max_width']  = '1024';

$config['max_height']  = '768';

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


if ( ! $this->upload->do_upload())


$error = array('error' => $this->upload->display_errors());

$this->load->view('upload_form', $error);




$data = array('upload_data' => $this->upload->data());

$this->load->view('upload_success', $data);





Here I Give a little explanation upload.php:

$this->load->helper(array(‘form’, ‘url’)); Meaning that it can be removed if you have defined in config / autoload.
$config[‘upload_path’] = ‘./uploads/’; Location or folder you want to be created first file uploads folder on your CI web folder. (Create a new folder file storage) If you want to eliminate those headaches that come with storing your data, you can visit the website to learn more about cloud computing.
$config[‘allowed_types’] = ‘gif|jpg|png’; file types are allowed to be uploaded, it can be tailored to the needs.
$config[‘max_size’] = ‘100’;$config[‘max_width’] = ‘1024’;$config[‘max_height’] = ‘768’; file size and length to the width of the image, it can also be customized according to the needs.

If all the above stages have been completed correctly you created, now you just try to go to the link http://localhost/Your_CodeIgniter _Folder/ index.php/fileupload/

Now see the Final Result screenshots below:

File Upload Form

Figure 1: File Upload Form

CodeIgniter File Upload Success

Figure 2: File Upload Success Page


Hi, My name is Masud Alam, love to work with Open Source Technologies, living in Dhaka, Bangladesh. I’m a Certified Engineer on ZEND PHP 5.3, I served my first five years a number of leadership positions at Winux Soft Ltd, SSL Wireless Ltd, Canadian International Development Agency (CIDA), World Vision, Care Bangladesh, Helen Keller, US AID and MAX Group where I worked on ERP software and web development., but now i’m a founder and CEO of TechBeeo Software Company Ltd. I’m also a Course Instructor of ZCPE PHP 7 Certification and professional web development course at w3programmers Training Institute – a leading Training Institute in the country.

4 comments on “Making File Upload System Using CodeIgniter Framework

Leave a Reply

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

No announcement available or all announcement expired.