网站首页  汉语字词  英语词汇  考试资料  写作素材  旧版资料

请输入您要查询的考试资料:

 

标题 PHP获取远程验证码到本地的PHP函数代码
内容
    PHP获取验证码图片到本地,支持png、gif、jpg三种格式的验证码。在实现时,PHP判断图片格式是使用的php内置的exif_imagetype函数,确实比较方便,学习PHP的不妨可参考下本代码:
    view sourceprint?01
    02header("Content-type:image/png");
    03set_time_limit(0);//设置超时时间
    04$url = $_GET['url'];
    05$url = "";
    06if(empty($url)){
    07 echo "没有图片";
    08 die;
    09}
    10$imginfo = GetImageSize ( $url );
    11$type = exif_imagetype($url);
    12$imgw = $imginfo [0];
    13$imgh = $imginfo [1];
    14$bg = imagecreatetruecolor($imgw,$imgh);
    15if($type==IMAGETYPE_GIF){
    16 $image = imagecreatefromgif($url);
    17}elseif($type==IMAGETYPE_JPEG){
    18 $image = imagecreatefromjpeg($url);
    19}elseif($type==IMAGETYPE_PNG){
    20 $image = imagecreatefrompng($url);
    21}
    22imagecolorallocate($image,255,255,255);
    23imagecopy($bg,$image,0,0, 0,0,$imgw,$imgh);
    24imagedestroy($image);
    25ImagePng($bg);
    26?>
随便看

 

在线学习网考试资料包含高考、自考、专升本考试、人事考试、公务员考试、大学生村官考试、特岗教师招聘考试、事业单位招聘考试、企业人才招聘、银行招聘、教师招聘、农村信用社招聘、各类资格证书考试等各类考试资料。

 

Copyright © 2002-2024 cuapp.net All Rights Reserved
更新时间:2025/5/25 5:14:59