为什么验证码图像在codeigniter中显示

Here is my code of captcha.php.I am new to codeigniter so please help me out. I want to display the captcha image in the browser but the image is not getting displayed over there. Can anyone tell me where i doing wrong.

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

class Captcha extends CI_Controller{

    public function index(){

        echo "HELLO CAPTCHA <br>";      

        $this->load->helper('captcha');


        $val = array(           
            'word'          => 'Random 123',
            'img_path'      => './Code__Igniter/application/captcha/',
            'img_url'       => 'http://localhost/Code__Igniter/index.php/captcha/',
            'font_path'     => './Code__Igniter/system/fonts/texb.ttf',
            'img_width'     => '300',
            'img_height'   => '50',
            'expiration'    => '3600', 
        );


        $img = create_captcha($val);

        echo $img['time'];
        echo $img['word'];

        $data['imag'] = $img['image'];  

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

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

    }
}

You just Have to

<div>
<?php
echo $imag;
?>
</div>

You have select wrong image path

'img_path'      => './Code__Igniter/application/captcha/',
'img_url'       => 'http://localhost/Code__Igniter/index.php/captcha/',

image url is folder path should not contain index.php its only folder path

crea image folder at main folder

like

Code__Igniter/captcha

now your $val array replace this two value

'img_path'      => './captcha/',
'img_url'       => 'http://localhost/Code__Igniter/captcha/',