Android客户端如何获取php客户端验证码图片

我用php写了个生成验证码和图片的文件(这个文件名为captcha.php),放在服务器端。
请问,Android客户端通过访问这个文件(通过url,如localhost/web/captcha.php)如何获取一张
验证码的图片?
php生成验证码及图片的代码如下:

<?php
header('Content-type:image/png');
require_once './function.php';
$width=65;
$height=20;
$image=imagecreate($width,$height);

$bg_color=imagecolorallocate($image,0x33,0x66,0xFF);
imagefilledrectangle($image,0,0,$width,$height,$bg_color);
$text=random(5);
$font=5;
$x=imagesx($image)/2-strlen($text)*imagefontwidth($font)/2;
$y=imagesy($image)/2-imagefontheight($font)/2;

$fg_color=imagecolorallocate($image,0xFF,0xFF,0xFF);
imagestring($image,$font,$x,$y,$text,$fg_color);

$_COOKIE['captcha']=$text;

imagepng($image);
imagedestroy($image);?>
阅读 7.1k
1 个回答
新手上路,请多包涵

解决了吗? 博主

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题