2011-07-05 55 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必須具有寫入權限。