验证码图片无法显示怎么回事?

yeyuanzhi2016 2019-01-09 01:35:39
<div class="jmllogin1" id="div_login" style="display:">
<ul>
<li class="spe1"><span id="login_info"></span></li>
<li><input class="user" onfocus="if(this.value=='用户名') {this.value='';}this.style.color='#cccccc';" onblur="if(this.value=='') {this.value='用户名';this.style.color='#ccc';}" value="用户名" type="text" id="userName" /></li>
<li><input class="password" onfocus="if(this.value=='密码') {this.value='';this.type='password';}this.style.color='#cccccc';" onblur="if(this.value=='') {this.value='密码';this.style.color='#ccc';this.type='text';}" value="密码" type="text" id="password" /></li>
</ul>
<li id="li_code" class="nli_code">
<div class="yzm_01">验证码  </div>
<div class="yzmhyh">
<span class="jmlma1"><input style="width:57px; height:16px; line-height:16px; margin:3px 0;" type="text" id="login_validateCode" maxlength="4" onclick="javascript:code_login();" onfocus="javascript:code_login();" onmouseover="javascript:code_login();" onblur="validateRegInfo('code');" /></span>

</div>
<img id="img_authCode1" class="jmlma2 njmlma2" src="__PUBLIC__/images/102914847.jpg" />
<em class="thyh"><a onclick="document.getElementById('img_authCode1').src='__APP__/Base/verify/v/'+Math.random();" style="cursor:pointer;">换一换?</a></em>
</li>
<div class="jmlbtn1"><input type="checkbox" id="autoLogin" checked /><span>下次自动登录</span>  |  <em><a href="__URL__/findBackPwdPage/" target="_self">忘记密码?</a></em></div>
<div class="jmlbtn2"><input type="button" id="btn_login" value="登录" onclick="login();" /></div>
<div class="jmlren1" >

</div>
</div>

usercenter.js代码:
    function switchAuthCode(){
$("#img_authCode").attr("src", "/index.php/Base/verify/rand/"+Math.random());
}

结果显示:

请问怎么解决?谢谢!
...全文
4992 13 打赏 收藏 转发到动态 举报
写回复
用AI写文章
13 条回复
切换为时间正序
请发表友善的回复…
发表回复
yeyuanzhi2016 2019-01-14
  • 打赏
  • 举报
回复
在import("ORG.Util.Image");前面加ob_clean();就可以了,谢谢各位!
三七– 2021-06-14
  • 举报
回复
@yeyuanzhi2016 import("ORG.Util.Image")在那个位置呀
дッボ重口味 2019-01-12
  • 打赏
  • 举报
回复
webview的支持问题?
weixin_44503473 2019-01-12
  • 打赏
  • 举报
回复
你直接访问验证码的地址能访问吗?
Java阿拉蕾 2019-01-11
  • 打赏
  • 举报
回复
路径说这压缩图片出现了问题
下雨的声音丶 2019-01-11
  • 打赏
  • 举报
回复
引用 3 楼 yeyuanzhi2016 的回复:
[quote=引用 1 楼 下雨的声音丶 的回复:] 你直接访问验证码的地址能访问吗?
怎么直接访问?[/quote] 把验证码图片标签的src 复制到浏览器打开 比如这个
yeyuanzhi2016 2019-01-11
  • 打赏
  • 举报
回复
引用 3 楼 yeyuanzhi2016 的回复:
[quote=引用 1 楼 下雨的声音丶 的回复:]
你直接访问验证码的地址能访问吗?

怎么直接访问?[/quote]
只找到下面验证码的地址
$("#img_authCode").attr("src", "/index.php/Base/verify/rand/"+Math.random());
/index.php/Base/verify/rand/是什么意思?怎么打开?
yeyuanzhi2016 2019-01-11
  • 打赏
  • 举报
回复
这是相关代码:
	public function verify() 
{
C('HTML_CACHE_ON',false);
import("ORG.Util.Image");
Image::buildImageVerify();
}

static function buildImageVerify($length=4, $mode=1, $type='png', $width=48, $height=22, $verifyName='verify') {
import('ORG.Util.String');
$randval = String::randString($length, $mode);
$_SESSION[$verifyName] = md5($randval);
$width = ($length * 10 + 10) > $width ? $length * 10 + 10 : $width;
if ($type != 'gif' && function_exists('imagecreatetruecolor')) {
$im = imagecreatetruecolor($width, $height);
} else {
$im = imagecreate($width, $height);
}
$r = Array(225, 255, 255, 223);
$g = Array(225, 236, 237, 255);
$b = Array(225, 236, 166, 125);
$key = mt_rand(0, 3);

$backColor = imagecolorallocate($im, $r[$key], $g[$key], $b[$key]); //背景色(随机)
$borderColor = imagecolorallocate($im, 100, 100, 100); //边框色
imagefilledrectangle($im, 0, 0, $width - 1, $height - 1, $backColor);
imagerectangle($im, 0, 0, $width - 1, $height - 1, $borderColor);
$stringColor = imagecolorallocate($im, mt_rand(0, 200), mt_rand(0, 120), mt_rand(0, 120));
// 干扰
for ($i = 0; $i < 10; $i++) {
imagearc($im, mt_rand(-10, $width), mt_rand(-10, $height), mt_rand(30, 300), mt_rand(20, 200), 55, 44, $stringColor);
}
for ($i = 0; $i < 25; $i++) {
imagesetpixel($im, mt_rand(0, $width), mt_rand(0, $height), $stringColor);
}
for ($i = 0; $i < $length; $i++) {
imagestring($im, 5, $i * 10 + 5, mt_rand(1, 8), $randval{$i}, $stringColor);
}
Image::output($im, $type);
}
三七– 2021-06-14
  • 举报
回复
@yeyuanzhi2016 放在什么文件呀 命名有什么要求吗
三七– 2021-06-14
  • 举报
回复
@yeyuanzhi2016 可以看看全部源码吗
yeyuanzhi2016 2019-01-10
  • 打赏
  • 举报
回复
引用 1 楼 下雨的声音丶 的回复:
你直接访问验证码的地址能访问吗?

怎么直接访问?
Csdn技术大神 2019-01-10
  • 打赏
  • 举报
回复
刷新试试行不行测试一下看报错
下雨的声音丶 2019-01-09
  • 打赏
  • 举报
回复
你直接访问验证码的地址能访问吗?

20,359

社区成员

发帖
与我相关
我的任务
社区描述
“超文本预处理器”,是在服务器端执行的脚本语言,尤其适用于Web开发并可嵌入HTML中。PHP语法利用了C、Java和Perl,该语言的主要目标是允许web开发人员快速编写动态网页。
phpphpstorm 技术论坛(原bbs)
社区管理员
  • 开源资源社区
  • phpstory
  • xuzuning
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧