重複の可能性:
php で動的に生成された画像で html を使用できますか?
PHPでキャプチャを生成しようとしています。コードは正しいと思いますが、ブラウザで画像を取得できません..これはコードです:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
<?php header('Content-type: image/png');?>
<?php session_start();
$md5 = md5(microtime() * time() );
$string = substr($md5, -5);
$captcha = imagecreatefrompng("./captcha.png");
$black = imagecolorallocate($captcha, 0, 0, 0);
$line = imagecolorallocate($captcha,233,239,239);
imageline($captcha,0,0,39,29,$line);
imageline($captcha,40,0,64,29,$line);
$_SESSION['key'] = md5($string);
imagestring($captcha, 5, 20, 10, $string, $black);
imagepng($captcha);?>
</body>
</html>
png 画像は、このコードと同じフォルダーにあります。GDオプションはphpで有効になっています..私は無知です..助けていただければ幸いです...ありがとう