codeigniter 验证码未显示在 iis 中

codeigniter captcha not showing in iis

我有一个 codeigniter 网站,我使用验证码,我的验证码在上一个服务器上工作,但在新服务器上没有创建也没有使用验证码 我使用 windows 服务器 2016 标准、IIS 10< PHP 7.0 和 Codeigniter 3.1

function index()
    {
        if ($this->session->userdata('us_login') == TRUE)
        {   
            redirect ('dashboard');
        }
        else
        {
            $data['captcha'] = $this->_create_captcha();
            $this->load->view('login', $data);  
        }
    }



function _create_captcha()
{
        $this->load->helper('captcha');
        // numeric random number for captcha
        $random_number = substr(number_format(time() * rand(),0,'',''),0,8);
        // setting up captcha config
        $vals = array(
            'word' => $random_number,
            'img_path' => './captcha/',
            'img_url' => base_url().'captcha/',
            'img_width' => 280,
            'img_height' => 45,
            'expiration' => 7200
            );
        $data['captcha'] = create_captcha($vals);
        $this->session->set_userdata('captchaWord',$data['captcha']['word']);
        return $data['captcha'];
}

this 中是您问题的答案。

在 Codeigniter 路径中 system/helpers/captcha_helper.php

你最变固定captcha_helper

-                   if (($rand_index = unpack('C', $bytes[$byte_index++])) > $rand_max)
+                   list(, $rand_index) = unpack('C', $bytes[$byte_index++]);
+                   if ($rand_index > $rand_max)