使用GD库创建验证码,没有结果,

时间:2014-01-20 14:55:05

标签: php gd captcha

当我检查索引页面时,除了图像损坏外,它不会显示任何内容。

这些是我正在使用的文件。

的index.php

<?php
session_start();

$_SESSION['secure'] = rand(1000, 9999);

?>

<img src="./generate.php" />

generate.php

<?php
session_start();
header('Content-type: image/jpeg');

$text = $_SESSION['secure'];
$font_size = 30;

$image_width = 110;
$image_height = 40;

$image = imagecreate($image_width, $image_height);
imagecolorallocate($image, 255, 255, 255);
$text_color = imagecolorallocate($image, 0, 0, 0);

imagettftext($image, $fon_size, 0, 15, 30, $text_color, 'font.ttf', $text);
imagejpeg($image);

0 个答案:

没有答案
相关问题