2011-07-05 52 views
1

我有以下代码,但我得到的是断开的链接!我已经安装了GD库和适当的字体!但没有任何工作,所以如何在zendframework中使用图像验证码而不会断链,出了什么问题?在zend框架captcha图像

$captcha = new Zend_Form_Element_Captcha('Captcha',array(
     'captcha' => array('captcha' => 'Image', 'wordLen' => 6, 
     'timeout' => 300, 'width' => 300, 'height' => 100, 
     'imgUrl' => '/captcha', 
     'imgDir' => APPLICATION_PATH . '/../public/captcha', 
     'font' => APPLICATION_PATH . '/../public/fonts/LiberationSansRegular.ttf'))); 

//对不起

+5

哪里是代码??? – Balanivash

+1

@sam,请张贴你提到的代码,否则没有人能够帮你纠正它;) – mingos

+0

你看过你的错误日志吗?此外,您可以通过右键单击和查看来查看图像。通常这会给你提示问题是什么。更多细节将会有所帮助。 – David

回答

0

尝试使用:

'/public/captcha' 

相反的:

APPLICATION_PATH . '/../public/captcha' 

-

我在程序做了什么是添加一对夫妇主要index.php文件中的行具有对public文件夹直接访问使用常数变量:

// Define path to public directory 
defined('PUBLIC_PATH') 
    || define('PUBLIC_PATH', realpath(dirname(__FILE__) . '/../public')); 

然后只需使用:

PUBLIC_PATH . '/captcha' 
0

我发现这个问题。它来自于:)

 if (in_array(strtolower(ini_get('magic_quotes_gpc')), array('1', 'on'))) { 
     $_POST = array_map('stripslashes', $_POST); 
     $_GET = array_map('stripslashes', $_GET); 
     $_COOKIE = array_map('stripslashes', $_COOKIE); 
     } 
0

APPLICATION_PATH。 '/../public/captcha'必须存在,并且apache/php必须具有写入权限。