0
我通过createCaptcha函数创建了一个验证码会话,该代码由我编写。 和在web服务我调用这个函数来创建一个验证码会话和图像,然后我想发送验证码图像或显示创建验证码图像的web服务,用户可以通过web服务发送它的价值,但我面临的错误。 实际上,而不是一个链接到该图像我得到一个编码的结果,当我测试它由Firefox加载项soap_client。无法通过nusoap webservice发送验证码图片
任何想法,我错了?
验证码功能代码:
<?php
session_start();
function createcaptcha($imgname)
{
/* Attempt to open */
$im = @imagecreatefromjpeg($imgname);
/* See if it failed */
if(!$im)
{
/* Create a black image */
$code=rand(1000,9999);
$_SESSION["code"]=$code;
$im = imagecreatetruecolor(50, 24);
$bg = imagecolorallocate($im, 22, 86, 165);
$fg = imagecolorallocate($im, 255, 255, 255);
imagefill($im, 0, 0, $bg);
/* Output an captcha code */
imagestring($im, 5, 5, 5, $code, $fg);
}
return $im;
}
GetCaptcha皂类:
session_start();
include_once('captcha.php');
class getCaptcha extends DBM
{
public function getcaptcha()
{
//creating and generating captcha image and code
$img = createcaptcha('captcha.png');
//encoding to base64
//$base64 = base64_encode($img);
$path = $img;
$type = pathinfo($path, PATHINFO_EXTENSION);
$data = file_get_contents($path);
$base64 = 'data:image/' . $type . ';base64,' . base64_encode($data);
$save = "/captchafile/captcha.png";
imagepng($base64, $save);
$captcha=$save;
$this->strResult = "";
$this->strResult.="<captcha>";
$this->strResult.="<captcha>$captcha</captcha>";
$this->strResult.="</captcha>";
}
function __toString()
{
if($this->strResult!=""){
return $this->strResult;
}
return "";
}
}
非常感谢。解决了我的问题。我没有考虑编码它..! – anonymox