0
我使用smarty和codeigniter。我的刷新驗證碼正確地在chrome中工作並更改了captcha的圖片,但它在firefox中不起作用,我的驗證碼不會更改。我的觀點的爲什麼我的刷新CAPTCHA在Firefox中不起作用?
部分:
<script>
function refreshCaptcha() {
$("#captcha_code").attr('src','{$url}Login/captcha');
}
</script>
</head>
<form class="m-t" role="form" action="{$url}admin/Dashboard"
method="POST">
<img id="captcha_code" src="{$url}Login/captcha" />
<a name="submit" class="btnRefresh" onClick="refreshCaptcha();">Refresh
Captcha</a>
</form>
我的控制器:
public function captcha()
{
$image = @imagecreatetruecolor(120, 30) or die("Cannot Initialize new GD
image stream");
$background = imagecolorallocate($image, 0xFF, 0xFF, 0xFF);
imagefill($image, 0, 0, $background);
$linecolor = imagecolorallocate($image, 0xCC, 0xCC, 0xCC);
$textcolor = imagecolorallocate($image, 0x33, 0x33, 0x33);
for($i=0; $i < 6; $i++)
{ imagesetthickness($image, rand(1,3));
imageline($image, 0, rand(0,30), 120, rand(0,30), $linecolor);}
session_start();
$digit = '';
for($x = 15; $x <= 75; $x += 20)
{ $digit .= ($num = rand(0, 9));
imagechar($image, rand(3, 5), $x, rand(2, 14), $num, $textcolor);
$_SESSION['captcha_code'] = $digit;
header('Content-type: image/png');
imagepng($image);
imagedestroy($image);
}
看:http://stackoverflow.com/questions/1077041/refresh-image-with-a-new -one-at-the-the-the-url – Lars
非常感謝你 – Rosa