2017-09-26 54 views
2

我已經在Zend表單中添加了驗證碼。在此驗證碼圖像自動生成並保存在驗證碼文件夾中。如何使用zend表單讀取寫入訪問路徑captcha

當在服務器(AWS)中訪問時,在沒有加載captcha圖像的html頁面中,因爲路徑不可讀可寫。

這裏是代碼我已經使用了與驗證碼創建了Zend形式:

$captcha = new Zend_Form_Element_Captcha('captcha', array(
                  'captcha' => array(
                   'captcha' => 'Image', 
                   'wordLen' => 5, 
                   'timeout' => 300, 
                   'expiration' => 300, 
                   'font' => './fonts/calibri_bold.ttf', 
                   'imgDir' => './captcha/', 
                   'imgUrl' => '/captcha/' 
                  ) 
              )); 

     $captcha->removeDecorator('ViewHelper'); 

如何使imgDir路徑與讀&寫訪問?

任何幫助,非常感謝。提前致謝。

回答

1

我通過在php中找到驗證碼圖像路徑並提供讀取圖像文件的訪問權限來解決此問題。以下是代碼:

public function giveCaptchaFolderAccess() { 
    $Path = realpath("../public/captcha"); 
    $dp = opendir($Path); 
    while ($File = readdir($dp)) { 
     if ($File != "." AND $File != "..") { 
      if (is_dir($File)) { 
       chmod($File, 0744); 
       chmod_r($Path . "/" . $File); 
      } else { 
       chmod($Path . "/" . $File, 0744); 
      } 
     } 
    } closedir($dp); 
} 
相關問題