【问题标题】:Whats wrong here in config array of Zend Captcha?Zend Captcha 的配置数组有什么问题?
【发布时间】:2013-07-03 19:58:36
【问题描述】:

我正在使用 Zend_Form_Element_Captcha 创建 Captcha 图像,如下所示:-

$captcha = new Zend_Form_Element_Captcha(
                   'captcha',
                    array(
                        'label' => 'Please write the characters you see in the image:',
                        'captcha' => array(
                                         'captcha' => 'Image',
                                         'wordLen' => 6,
                                         'timeout' => 900,
                                          'font' => '/usr/share/fonts/truetype/ttf-dejavu/DejaVuSans.ttf',

                                     )
                        )
    );

$form = new Zend_Form();

$form->addElement($captcha);

这是在创建验证码图像,但方式不正确。 字母完全不可读。 这就是我得到的......

我也尝试更改字体,但结果相同。有什么建议吗?

【问题讨论】:

  • 你试过用其他字体吗?
  • 是的,正如我所说,我的结局是一样的。我也只尝试了'font'=>'arial',但同样的结果。
  • 您确定它正在访问您分配的字体目录吗?
  • 不,我该如何检查? (但它也没有显示任何错误)

标签: php zend-framework captcha


【解决方案1】:

我已在本地环境中尝试过您的代码。如果您使用的是 Windows,请使用以下代码。 我使用了字体的绝对路径。

$captcha = new Zend_Form_Element_Captcha(
                        'captcha',
                        array(
                            'label' => 'Please write the characters you see in the image:',
                            'captcha' => array(
                                'captcha' => 'Image',
                                'wordLen' => 6,
                                'timeout' => 900,
                                'font' => 'C:/Windows/Fonts/Arial.ttf',
                                'imgDir' => APPLICATION_PATH . '/../public/captcha/',
                                'imgUrl' => '/captcha/'
                            )
                        )
        ); 

【讨论】:

    【解决方案2】:

    试试这个

    $captcha = new Zend_Form_Element_Captcha(
       'captcha',
        array(
            'label' => 'Please write the characters you see in the image:',
            'captcha' => array(
                 'captcha' => 'Image',
                 'wordLen' => 6,
                 'timeout' => 900,
                 'dotNoiseLevel' => 20,
                 'lineNoiseLevel' => 3,
                 'fontSize' => 25,
                 'font' => '/usr/share/fonts/truetype/ttf-dejavu/DejaVuSans.ttf',
    
             )
            )
    );
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-07-09
      • 2017-03-08
      • 2014-01-13
      • 2014-04-11
      • 2011-09-11
      • 2013-07-17
      • 1970-01-01
      • 2012-05-07
      相关资源
      最近更新 更多