我对gd2图片库做错了 这是我的索引控制器
public function index()
{
$config['image_library'] = 'gd2';
$this->load->library('image_lib', $config);
$vals = array(
'img_path' => './captcha/',
'img_url' => base_url().'public/img/captcha/',
'img_width' => '200',
'img_height' => 30,
'border' => 0,
'expiration' => 7200,
);
// create captcha image
$cap = create_captcha($vals);
print_r($cap);
// store image html code in a variable
$arrData['image'] = $cap['image'];
// store the captcha word in a session
$this->session->set_userdata('word', $cap['word']);
$arrData['middle'] = 'contact';
$this->load->view('template',$arrData);
}
以上代码是我的控制器索引函数
这是我的观点
<div class="enquiry-deatils">
<label>Type character * :</label>
<input type="text" placeholder="" class="captcha"/>
<label><img src="images/capcha.jpg" /></label>
<?php echo $image; // this will show the captcha image ?>
</div>
我不知道它给我什么都没有的错误
答案 0 :(得分:0)
试试这个 - 提供img_path和img_url的完整路径。像这样 -
$vals = array(
'img_path' => 'mysite/public/img/captcha/',
'img_url' => 'mysite/public/img/captcha/',
'img_width' => '150',
'img_height' => 30,
'expiration' => 7200,
"time" => time()
);