我会尝试尽可能具体。我使用codeigniter验证码助手在我的网站上生成用于验证用户的验证码,它在ly localhost上运行良好,但是当我在线上传网站时,验证码没有显示任何内容,显然,当我使用开发人员工具img标签查看它时根本没有包含验证码图片的图片。

代码是:

$this->load->helper('captcha');
$vals = array(
        'img_path' => './captcha/',
        'img_url' => base_url().'captcha/',
        'font_path' => './fonts/VeraSe.ttf',
        );

$img = create_captcha($vals);
$x = $this->session->set_userdata('captcha', $img['word']);

$data['image'] = $img['image'];
$data['captcha1'] = $img['word'];
$this->load->view('signup', $data);


并在视图中:

<?php echo $image; ?>

最佳答案

看来该脚本有一些问题,它需要额外的参数,有效的代码是:

$vals = array(

    'img_path' => './captcha/',
    'img_url' => 'http://example.com/captcha/',
    'font_path' => './fonts/texb.ttf',
    'img_width' => '150',
    'img_height' => 30,
    'expiration' => 7200
    );

$cap = create_captcha($vals);
$data = $cap['image'];
$this->load->view(signup, $data);


并在视图文件中

echo $image;

10-05 20:42
查看更多