Tuesday, 10 March 2015

Display image from a folder in Codeigniter

(1)write  code for  "displayimage.php"  fiel & save into views folder:

<?php

$this->load->helper('directory'); //load directory helper

$dir = "uploads/"; // Your Path to folder

$map = directory_map($dir); /* This function reads the directory path specified in the first parameter and builds an array representation of it and all its contained files. */


foreach ($map as $k)

{?>
     <img src="<?php echo base_url($dir)."/".$k;?>"  height="200"  width="200"   alt="">
  
<?php }
         
?>




(2)write code for upload_controller.php file  & save inot controllers:


<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');


class  Upload_Controller extends CI_Controller

{

public function __construct()

{
parent::__construct();

$this->load->helper('url');
}

public function displayimage()

{

$this->load->view('displayimage');



}


}


?>


(3)to run  it open browser & type following code:

  "localhost/ci/index.php/upload_controller/displayimage"

9 comments:

  1. nice post bro www.gajabwap.blogspot.in

    ReplyDelete
  2. I like your awesome and briefing information's how to get lots of followers on instagram instantly and i was looking for these types of knowledge.

    ReplyDelete
  3. Great post dear. It definitely has increased my knowledge on Spark, Epilator Pain Please keep sharing similar write ups of yours.

    ReplyDelete
  4. beneficial post please if you make you way of path comfertable so you should 2019 's best corcoran boots to buy for comfrt zone.

    ReplyDelete
  5. beneficial post please if which kissanime is real you make you way of path comfertable so you should 2019 's best gogoanime corcoran boots to buy for comfrt zone.

    ReplyDelete
  6. beneficial post please if watch prison school season 2 you make you way of path comfertable so you should 2019 's best gogoanimes corcoran boots to buy for comfrt zone.

    ReplyDelete
  7. This is the really great post, I like Captain Marvel Leather Jacket I am interested in reading this post.

    ReplyDelete
  8. Nice Post. How could we use pagination while displaying image from folder in codeigniter?

    ReplyDelete