TTF 파일을 찾을 수 있지만, 어떤 이유로 나는 (로그 파일)이 오류가 발생합니다 :PHP 보안 문자는 내 사이트에 보안 문자를 추가 할 필요가
: 여기Warning: imagettfbbox(): Could not find/open font in /home/eric/www/captcha.php on line 24
Warning: imagettftext(): Could not find/open font in /home/eric/www/captcha.php on line 27
내 코드입니다
function generate($width,$height,$characters='6') {
$code = '';
$availableChar = '23456789bcdfghjkmnpqrstvwxyz';
$i = 0;
while ($i < $characters) {
$code .= substr($availableChar, mt_rand(0, strlen($availableChar)-1), 1);
$i++;
}
$image = imagecreate($width, $height);
$text = imagecolorallocate($image, 20, 40, 100);
$things = imagecolorallocate($image, 100, 120, 180);
for($i=0; $i<($width*$height)/3; $i++) {
imagefilledellipse($image, mt_rand(0,$width), mt_rand(0,$height), 1, 1, $things);
}
for($i=0; $i<($width*$height)/150; $i++) {
imageline($image, mt_rand(0,$width), mt_rand(0,$height), mt_rand(0,$width), mt_rand(0,$height), $things);
}
$textbox = imagettfbbox($height, 0, 'monofont.ttf', $code);
imagettftext($image, $height, 0, (($width - $textbox[4])/2), (($height - $textbox[5])/2), $text, 'monofont.ttf' , $code);
imagejpeg($image);
imagedestroy($image);
return $code;
}
header('Content-Type: image/jpeg');
$code = generate(100, 40, 5);
echo $_SESSION['security_code'] = $code;
내 폴더에있는 파일을
-rwxr-xr-x 1 tech4wilco tech4wilco 41036 1999-07-13 23:30 monofont.ttf
-rw-r--r-- 1 tech4wilco tech4wilco 1030 2011-10-17 15:43 captcha.php
내가 뒷조사를했고, 내가 발견하는 글꼴이 있어야하고 그것이 샘에있어 볼 수 있습니다 전자 파일을 PHP 파일로 저장하고 싶습니다.
오류를 검사하지 않습니다. 이러한 모든 함수 (imagejpeg와 같은)는 부울 또는 그 성공을 나타내는 기타 정보를 반환합니다. 그 결과를 잡아서 잘못 된 부분을 좁히십시오. – GolezTrol
사용중인 GD 라이브러리와 관련이있을 수 있습니다. PHP 문서에서 "PHP가 사용하는 GD 라이브러리의 버전에 따라 파일 이름에 '.ttf'를 추가하고 라이브러리를 따라 검색하여 선도 문자 '/'로 시작하지 않는 파일을 검색하려고 할 수 있습니다 정의 된 글꼴 경로. " 아마도 monofont.ttf.ttf를 찾고 있었을 것입니까? –