dictionary.txt라는 파일에서 단어를 가져 와서 GD 라이브러리를 사용하여 captcha 이미지로 변환하는 보안 문자를 만들려고합니다. 그러나 뭔가 잘못되었습니다. 사전 변수를 세션 변수로 표시 할 수는 있지만 이미지를 만들지는 못합니다. GD 라이브러리 코드 여야합니다. captcha_validate.php라는 최종 타겟 파일이 있지만, 지금은 중요하지 않습니다. 나는 단지 이미지가 작동하도록 노력하고있다. 폰트 경로가 설정되면 바로 form_captcha.php보안 문자가 php에 나타나지 않습니다
<form class="" action="captcha_validate.php" method="post">
Captcha Verify:
<input type="text" name="captcha" value="" /><br /><br />
<img src="captcha.php" /><br />
<input type="submit" name="submit" value="Submit" />
</form>
captcha.php
<?php
session_start();
session_regenerate_id();
$file = file('dictionary.txt', FILE_IGNORE_NEW_LINES);
$length = count($file) - 1;
$random = rand(0, $length);
$_SESSION['captcha'] = $file[$random];
session_write_close();
function msg($msg) {
$container = imagecreate(250, 170);
$black = imagecolorallocate($container, 0, 0, 0);
$white = imagecolorallocate($container, 255, 255, 255);
$font = "C:\Windows\Fonts\arial.ttf";
imagefilledrectangle($container, 0, 0, 250, 170, $black);
$px = (imagesx($container)/(strlen($msg)/1.15));
$py = (imagesy($container)/3.5);
imagefttext($container, 28, -27, $px, $py, $white, $font, $msg);
header("Content-type: image/png");
imagepng($container, null);
imagedestroy($container);
}
msg($file[$random]);
?>
'Imagepng' man 페이지에'quality와 filters 인수가 사용되지 않으면 NULL이 유효하지 않습니다. ' –
나는 이것을했고 여전히 효과가 없다. imagepng ($ 컨테이너, null, 0, PNG_NO_FILTER); –