传到外部服务器(linux)上以后,图片验证码那是个X,不能显示图片 你运行个phpinfo()看看自己的服务器和外部服务器有什么区别没? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 上www.cgxtd.com看视频那块,需要安装xp2的XXXXXXX 再看下HTTP_ACCEPT项,是否支持PNG输出 还有在php.ini中有个叫session什么的信息可以参考改一个值试试 兄弟多多指教,我以前用IIS,从网上拷下来一段代码OK,现在用APACHE,就有问题了 PHP图片验证码原代码,需支持gd2.dll扩展,需修改PHP.ini后重启IIS or ap 调用方法<img src="this.php"> 程序代码: <?PHP session_start(); session_register('SafeCode'); $type = 'gif'; $width= 40; $height= 16; header("Content-type: image/".$type); srand((double)microtime()*1000000); $randval = randStr(4,""); if($type!='gif' && function_exists('imagecreatetruecolor')){ $im = @imagecreatetruecolor($width,$height); }else{ $im = @imagecreate($width,$height); } $r = Array(225,211,255,223); $g = Array(225,236,237,215); $b = Array(225,236,166,125); $key = rand(0,3); $backColor = ImageColorAllocate($im,$r[$key],$g[$key],$b[$key]);//背景色(随机) $borderColor = ImageColorAllocate($im, 0, 0, 0);//边框色 $pointColor = ImageColorAllocate($im, 255, 170, 255);//点颜色 @imagefilledrectangle($im, 0, 0, $width - 1, $height - 1, $backColor);//背景位置 @imagerectangle($im, 0, 0, $width-1, $height-1, $borderColor); //边框位置 $stringColor = ImageColorAllocate($im, 255,51,153); for($i=0;$i<=100;$i++){ $pointX = rand(2,$width-2); $pointY = rand(2,$height-2); @imagesetpixel($im, $pointX, $pointY, $pointColor); } @imagestring($im, 3, 5, 1, $randval, $stringColor); $ImageFun='Image'.$type; $ImageFun($im); @ImageDestroy($im); $_SESSION['SafeCode'] = $randval; //产生随机字符串 function randStr($len=6,$format='ALL') { switch($format) { case 'ALL': $chars='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'; break; case 'CHAR': $chars='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'; break; case 'NUMBER': $chars='0123456789'; break; default : $chars='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'; break; } $string=""; while(strlen($string)<$len) $string.=substr($chars,(mt_rand()%strlen($chars)),1); return $string; } ?> 关于symfony的问题 请教 php 正则提取日期的问题 写入MYSQL存在的问题! 怎么csdn论坛越发展越不好用,现在那个搜索是个什么东东,根本找不到想要找的东东,不上了?气死个人 怎樣才能修改圖片 从mysql_connect得到值 菜鸟求救:php获取元素ID根据id不同调用不用的文件并解析模板 你们遇到过这种情况吗?PHP极度不解的困惑,大家帮帮我 在内容中添加.或/或多了,页面就不会按以前的格式显示 中专生为什么不被社会重视,社会为什么对我们这样,大家评一评? 二周不用登录 这个是怎么实现的? 100分巨献:请大家评评joomla
session_start();
session_register('SafeCode');
$type = 'gif';
$width= 40;
$height= 16;
header("Content-type: image/".$type);
srand((double)microtime()*1000000);
$randval = randStr(4,"");
if($type!='gif' && function_exists('imagecreatetruecolor')){
$im = @imagecreatetruecolor($width,$height);
}else{
$im = @imagecreate($width,$height);
}
$r = Array(225,211,255,223);
$g = Array(225,236,237,215);
$b = Array(225,236,166,125); $key = rand(0,3); $backColor = ImageColorAllocate($im,$r[$key],$g[$key],$b[$key]);//背景色(随机)
$borderColor = ImageColorAllocate($im, 0, 0, 0);//边框色
$pointColor = ImageColorAllocate($im, 255, 170, 255);//点颜色 @imagefilledrectangle($im, 0, 0, $width - 1, $height - 1, $backColor);//背景位置
@imagerectangle($im, 0, 0, $width-1, $height-1, $borderColor); //边框位置
$stringColor = ImageColorAllocate($im, 255,51,153); for($i=0;$i<=100;$i++){
$pointX = rand(2,$width-2);
$pointY = rand(2,$height-2);
@imagesetpixel($im, $pointX, $pointY, $pointColor);
} @imagestring($im, 3, 5, 1, $randval, $stringColor);
$ImageFun='Image'.$type;
$ImageFun($im);
@ImageDestroy($im);
$_SESSION['SafeCode'] = $randval;
//产生随机字符串
function randStr($len=6,$format='ALL') {
switch($format) {
case 'ALL':
$chars='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'; break;
case 'CHAR':
$chars='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'; break;
case 'NUMBER':
$chars='0123456789'; break;
default :
$chars='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
break;
}
$string="";
while(strlen($string)<$len)
$string.=substr($chars,(mt_rand()%strlen($chars)),1);
return $string;
}
?>