如何使用zend表单读取写入访问路径captcha
问题描述:
我已经在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
路径与读&写访问?
任何帮助,非常感谢。提前致谢。
答
我通过在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);
}