最新消息: 新版网站上线了!!!

php上传头像检测是不是木马

$file_name_with_full_path = $_FILES['file']['tmp_name'];
        $arr = array(1=>"image/jpeg",2=>"image/png",3=>"image/gif",4=>"image/jpg");
        if (in_array($_FILES['file']['type'],$arr)) {//后缀是图片
            list($width, $height, $type, $attr) = getimagesize($file_name_with_full_path);
            if (array_key_exists($type,$arr)) {//确定其内容是真正的图片
                $file_name_with_full_path = $file_name_with_full_path;
            } else {
                echo "伪造的图片";
 @unlink($_FILES['file']['tmp_name']);
                exit;
            }
        }  else {
            echo "图片格式不合格!,请使用png,gif,jpg";
 @unlink($_FILES['file']['tmp_name']);
            exit;
        }

转载请注明:谷谷点程序 » php上传头像检测是不是木马