using-zf3-book-samples
using-zf3-book-samples copied to clipboard
Captcha font issue
Hi, I'm getting warning error in Reset Password page and couldnt able to reset password.
Warning: imageftbbox(): Could not find/open font in C:\xampp\htdocs\userdemo\vendor\zendframework\zend-captcha\src\Image.php on line 510
Warning: imagefttext(): Could not find/open font in C:\xampp\htdocs\userdemo\vendor\zendframework\zend-captcha\src\Image.php on line 513
Screenshot attached for reference. Please help me on that
make sure you have created the folder: captcha: public/img/captcha and the folder font inside data: AppName/data/font/thorne_shade.ttf
then: setup the captcha form element inside the PasswordResetForm.php ... .. 'captcha' => [ 'class' => 'Image', 'imgDir' => 'public/img/captcha', 'suffix' => '.png', 'imgUrl' => 'img/captcha/', 'imgAlt' => 'CAPTCHA Image', 'font' => './data/font/thorne_shaded.ttf', .. .. ..
I resolved this problem with the after-mentioned. Good Luck.
make sure you have created the folder: captcha: public/img/captcha and the folder font inside data: AppName/data/font/thorne_shade.ttf
then: setup the captcha form element inside the PasswordResetForm.php ... .. 'captcha' => [ 'class' => 'Image', 'imgDir' => 'public/img/captcha', 'suffix' => '.png', 'imgUrl' => 'img/captcha/', 'imgAlt' => 'CAPTCHA Image', 'font' => './data/font/thorne_shaded.ttf', .. .. ..
I resolved this problem with the after-mentioned. Good Luck.
Above mentioned code is already there in my code. No Luck.
have you active the GD php extension?
have you active the GD php extension?
Yes it is active.
hola alguien ya soluciono este error es que no puedo pasar de este error igual tengo activa la extensión gd y el archivo PasswordResetForm.php esta igual. por favor soy nuevo en esto
I was struggling also with this in Windows. I found out that the 'font' key should be made with realpath() (I believe is an issue with the imagefbbox function). Also, as I did not setup VirtualHost, I had to add './' in the 'imgDir' key
$this->add([ 'type' => 'captcha', 'name' => 'captcha', 'options' => [ 'label' => 'Human check', 'captcha' => [ 'class' => 'Image', 'imgDir' => './public/img/captcha', //added ./ 'suffix' => '.png', 'imgUrl' => 'img/captcha/', 'imgAlt' => 'CAPTCHA Image', 'font' => realpath('./data/font/thorne_shaded.ttf'), //added realpath 'fsize' => 24, 'width' => 350, 'height' => 100, 'expiration' => 600, 'dotNoiseLevel' => 40, 'lineNoiseLevel' => 3 ], ], ]);
Hope this helps!
@heldersoares
thank you friend, excellent contribution it worked correctly
:)