Posted inProgramming / Mysql / Mysqli / php

PHP Codeigniter Image File Upload

PHP Codeigniter Image File Upload

Today, We want to share with you PHP Codeigniter Image File Upload.
In this post we will show you How to Image and File Upload in Codeigniter, hear for Codeigniter File Upload Tutorial With PHP Code Examples we will give you demo and example for implement.
In this post, we will learn about How to Upload Image and File in CodeIgniter with an example.

upload file/image in CodeIgniter my latest post is about the CodeIgniter framework(C.I.) file or image upload.
By the use of the file uploading class in codeigniter Framework, you can easily upload a file or an image.
CodeIgniter’s framework File Uploading Class used to permits files or image to be uploaded.

CI – Uploading a file all involves the following list of Simple process:

here , An upload form (Using HTML form)is displayed, allowing a user to select a new file or images and upload it folder.
When the form(HTML form) is submitted (using POST Method), the file or image is uploaded to (root upload folder)the destination you specify(Like uploads directory in root).
and Along the way(other), the file or image is validated(Like jpg,png,etc..) to make sure it is (check format) allowed to be uploaded based and display message on the preferences you set(using ci).
successfully upload file or images Once uploaded, to the user will be show a success message here form.

Following the all steps display in the given best example easy to understand the file or images uploading process(Step by step) in CodeIgniter framework.

Step By step – Creating the Upload Form using CodeIgniter Framework

Folder Path : applications/views/ci_upload_form.php.




Upload Form - CodeIgniter - File Uploading











The Success Page

applications/views/upload_success.php




Upload Form - CodeIgniter Image and File Upload



Your CodeIgniter Framework file was successfully easy way to uploaded!

    $value):?> // Foreach start
  • :
  • //looping //End For each

The Controller File

Folder Path : applications/controllers/upload.php


class Upload extends CI_Controller {

	function __construct()
	{
		parent::__construct();
		$this->load->helper(array('form', 'url'));
	}

	function index()
	{
		$this->load->view('ci_upload_form', array('disperrorgenrate' => ' ' ));
	}

	function do_upload()
	{
		$config['upload_path'] = './imageuploads/'; //upload images path
		$config['allowed_types'] = 'gif|jpg|png'; // file format validation
		$config['max_size']	= '142'; // images max size
		$config['max_width']  = '1250'; // images max width
		$config['max_height']  = '789'; // images max height

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

		if ( ! $this->upload->do_upload())
		{
			$disperrorgenrate = array('disperrorgenrate' => $this->upload->display_disperrorgenrates());

			$this->load->view('ci_upload_form', $disperrorgenrate);
		}
		else
		{
			$data = array('data_upload_data' => $this->upload->data());

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

Create The Upload Folder in your codeigniter framework applications

You will need a one destination (images upload folder) folder for your file or images uploaded images.new Create a folder at the root directory of your CodeIgniter framework installation applications_name called uploads and set it is the file all permissions to 777(read,write or upload).

Excute : Try it!

Pakainfo.com/index.php/upload/

I am Jaydeep Gondaliya , a software engineer, the founder and the person running Pakainfo. I'm a full-stack developer, entrepreneur and owner of Pakainfo.com. I live in India and I love to write tutorials and tips that can help to other artisan, a Passionate Blogger, who love to share the informative content on PHP, JavaScript, jQuery, Laravel, CodeIgniter, VueJS, AngularJS and Bootstrap from the early stage.

Leave a Reply

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

We accept paid guest Posting on our Site : Guest Post Chat with Us On Skype