php ipv6 验证表达式

 更新时间:2016年11月25日 15:59  点击:2101

<?php
// literally from the ABNF in rfc3986 (thanks to 'WCP')
function validateIPv6($IP)
{
    return preg_match('/A
        (?:
            (?:
                    (?:[a-f0-9]{1,4}:){6}
                |
                    ::(?:[a-f0-9]{1,4}:){5}
                |
                    (?:[a-f0-9]{1,4})?::(?:[a-f0-9]{1,4}:){4}
                |
                    (?:(?:[a-f0-9]{1,4}:){0,1}[a-f0-9]{1,4})?::(?:[a-f0-9]{1,4}:){3}
                |
                    (?:(?:[a-f0-9]{1,4}:){0,2}[a-f0-9]{1,4})?::(?:[a-f0-9]{1,4}:){2}
                |
                    (?:(?:[a-f0-9]{1,4}:){0,3}[a-f0-9]{1,4})?::[a-f0-9]{1,4}:
                |
                    (?:(?:[a-f0-9]{1,4}:){0,4}[a-f0-9]{1,4})?::
            )
                (?:
                        [a-f0-9]{1,4}:[a-f0-9]{1,4}
                    |
                        (?:(?:[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5]).){3}
                            (?:[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])
                )
            |
                (?:
                        (?:(?:[a-f0-9]{1,4}:){0,5}[a-f0-9]{1,4})?::[a-f0-9]{1,4}
                    |
                        (?:(?:[a-f0-9]{1,4}:){0,6}[a-f0-9]{1,4})?::
                )
        )Z/ix',
        $IP
    );
}
?>

php discuz chhome 图片上传swfupload功能
这上传与discuz来比, 还相差太远. 功能也欠缺.
  除了部分内置的url引向,我们改不了之外, 其它的数据都是可以修改的.
<?php
/*
 [UCenter Home] (C) 2007-2008 Comsenz Inc.
 $Id: do_swfupload.php 12830 2009-07-22 06:42:32Z zhengqingpeng $
*/

if(!defined('IN_UCHOME')) {  //入门牌.
 exit('Access Denied');
}

include_once(S_ROOT.'./source/function_cp.php');

$op = empty($_GET['op'])?'':$_GET['op'];  // uchome比较喜欢用的方法变量.
$isupload = empty($_GET['cam']) && empty($_GET['doodle']) ? true : false;  //是否上传.还有种可能是头像上传.
$iscamera = isset($_GET['cam']) ? true : false;  //判断一下是头像上传.
$isdoodle = isset($_GET['doodle']) ? true : false;  //判断一下是大头贴背景是否随机.
$fileurl = ''; // 默认赋值.
if(!empty($_POST['uid'])) {  //如果有uid传过来, 表示在上传头像, 就取得uid值.
 $_SGLOBAL['supe_uid'] = intval($_POST['uid']);    //强制转化.
 if(empty($_SGLOBAL['supe_uid']) || $_POST['hash'] != md5($_SGLOBAL['supe_uid'].UC_KEY)) {  // 既然传递了uid值是过来, 假如用户没有登录,及hash码不对应,就中断.
  exit();
 }
} elseif (empty($_SGLOBAL['supe_uid'])) {  //否则再判断, 如果没有登录, 禁止使用上传功能.
 showmessage('to_login', 'do.php?ac='.$_SCONFIG['login_action']);
}

if($op == "finish") {  //上传结束时.
 /* 它会传入如下GET
 array (
           'ac' => 'swfupload',
           'op' => 'finish',
           'albumid' => '2',
   )*/
 $albumid = intval($_GET['albumid']);  //取得分类id.
 $space = getspace($_SGLOBAL['supe_uid']); //更新用户部分记录, 比较图片总数, 容量计算.
 if(ckprivacy('upload', 1)) {  //判断一下是否已经写了推送.
  include_once(S_ROOT.'./source/function_feed.php');
  feed_publish($albumid, 'albumid');  //否则就再写一次.
 }
 //强行中断.
 exit();
} elseif($op == 'config') {  //swf上传的配置.
 /* 根据抓取所得 GET传过来:
         array (
           'ac' => 'swfupload',
           'op' => 'config',
 )
 */
 $hash = md5($_SGLOBAL['supe_uid'].UC_KEY); //生成一个hash码.
 
 if($isupload && !checkperm('allowupload')) {  //是上传图片,并且权限足够.对于配置来说, $isupload永远为假.
  $hash = '';
 } else {
  $filearr = $dirstr = array();  //初始化数组.  文件数组/及目录数据.

  if($iscamera) {  //进入头像上传工作.
   /*
    根据抓取, GET数据如下:
    array (
             'ac' => 'swfupload',
             'op' => 'config',
             'cam' => '1',
    )
   */
   $directory = sreaddir(S_ROOT.'./image/foreground'); //大头贴背景的目录. sreaddir读取里面的目录数据.
   foreach($directory as $key => $value) {   //每一个背景都是独立的一个目录, 所以循环一下.
    $dirstr = S_ROOT.'./image/foreground/'.$value;  //合成新的路径.
    if(is_dir($dirstr)) { //判断一下是否是目录.
     $filearr = sreaddir($dirstr, array('jpg','jpeg','gif','png')); //读取目录里面的图片文件.
     if(!empty($filearr)) {   // 如果图片数组不为空.
      if(is_file($dirstr.'/categories.txt')) {  // 如果categories.txt文件存在.
       $catfile = @file($dirstr.'/categories.txt');   //打开此文件.
       $dirarr[$key][0] = trim($catfile[0]);  //就将里面的文件读取来. 当然, 很无谓的方法, 里面的内容与目录名是一样的.
      } else {   //如果txt文件不存在, 就取得目录名.
       $dirarr[$key][0] = trim($value);  //准确取得值, trim多用.
      }
      $dirarr[$key][1] = trim('image/foreground/'.$value.'/');  //将指针1设置为当前大头贴背景目录.
      $dirarr[$key][2] = $filearr;  // //将指针2设置为当前大头贴背景目录里面的图片.
     }
    }
   }
  } elseif($isdoodle) { //如果是头像随机背景, 就读取./image/doodle/big里面的图片文件.
   $filearr = sreaddir(S_ROOT.'./image/doodle/big', array('jpg','jpeg','gif','png'));
  }
 }
 //接着就到了图片上传配置工作.
 $max = @ini_get(upload_max_filesize); //取得php.ini最大上传值.
 $unit = strtolower(substr($max, -1, 1));  //$max结尾有kb字样吧, 要截取一下,并且转成小写.
 
 //下面是针对不同的计算单元作换算.
 if($unit == 'k') {
  $max = intval($max)*1024;   //看样子是全部转成byt字节单位. KB X 1024 = 多少字节.
 } elseif($unit == 'm') {
  $max = intval($max)*1024*1024; // MB X 1024 X 1024 = 多少字节.
 } elseif($unit == 'g') {
  $max = intval($max)*1024*1024*1024;  // GB X 1024 X 1024 X 1024 = 多少字节.
 }
 //取得用户所建立的分类数组.
 $albums = getalbums($_SGLOBAL['supe_uid']);
 
} elseif($op == "screen" || $op == "doodle") {  // screen 不理解什么时候出来 || 随机大头贴背景,由于没有摄像头, 这里面略过.
 
 if(empty($GLOBALS['HTTP_RAW_POST_DATA'])) { 
  $GLOBALS['HTTP_RAW_POST_DATA'] = file_get_contents("php://input");
 }
 $status = "failure";
 $dosave = true;
 
 if($op == "doodle") { 
  $query = $_SGLOBAL['db']->query('SELECT * FROM '.tname('usermagic')." WHERE uid = '$_SGLOBAL[supe_uid]' AND mid = 'doodle'");
  $value = $_SGLOBAL['db']->fetch_array($query);
  if(empty($value) || $value['count'] < 1) {//&ucirc;��Ϳѻ��
   $uploadfiles = -8;
   $dosave = false;
  }
 }
 

 if($dosave && !empty($GLOBALS['HTTP_RAW_POST_DATA'])) {
  $_SERVER['HTTP_ALBUMID'] = addslashes(siconv(urldecode($_SERVER['HTTP_ALBUMID']), $_SC['charset'], "UTF-8"));
  $from = false;
  if($op == 'screen') {
   $from = 'camera';
  } elseif($_GET['from'] == 'album') {
   $from = 'uploadimage';
  }
  $_SCONFIG['allowwatermark'] = 0; 
  $uploadfiles = stream_save($GLOBALS['HTTP_RAW_POST_DATA'], $_SERVER['HTTP_ALBUMID'], 'jpg', '', '', 0, $from);
 }
 
 $uploadResponse = true;
 $picid = $proid = $albumid = 0;
 if($uploadfiles && is_array($uploadfiles)) {
  $status = "success";
  $albumid = $uploadfiles['albumid'];
  $picid =  $uploadfiles['picid'];   
  if($op == "doodle") {   
   $fileurl = pic_get($uploadfiles['filepath'], $uploadfiles['thumb'], $uploadfiles['remote'], 0);
   include_once(S_ROOT.'./source/function_magic.php');
   magic_use('doodle', array(), 1);
  }
 } else {
  switch ($uploadfiles) {
   case -1:
    $uploadfiles = cplang('inadequate_capacity_space');
    break;
   case -2:
    $uploadfiles = cplang('only_allows_upload_file_types');
    break;
   case -4:
    $uploadfiles = cplang('ftp_upload_file_size');
    break;
   case -8:
    $uploadfiles = cplang('has_not_more_doodle');
    break;
   default:
    $uploadfiles = cplang('mobile_picture_temporary_failure');
    break;
  }
 }

} elseif($_FILES && $_POST) {   // 图片上传时,
 /* 根据抓取, POST GET数据值为:
 POST = array (
           'Filename' => 'MJP45+R3001.jpg',
           'proid' => '1',
           'albumid' => '2',
           'uid' => '1',
           'title' => 'MJP45+R3001',
           'hash' => '11ed07fe235ca5b9e509043e85419785',
           'Upload' => 'Submit Query',
 )
 
 GET = array (
          'ac' => 'swfupload',
 )
 
 */
 if($_FILES["Filedata"]['error']) { //如果有上传错误
  $uploadfiles = cplang('file_is_too_big'); // 就提示文件过大.
 } else {
  //考虑到编码及大小写问题, 还有转义. 取得上传文件名.
  $_FILES["Filedata"]['name'] = addslashes(siconv(urldecode($_FILES["Filedata"]['name']), $_SC['charset'], "UTF-8"));
  //考虑到编码及大小写问题, 还有转义. 取得上传分类id.
  $_POST['albumid'] = addslashes(siconv(urldecode($_POST['albumid']), $_SC['charset'], "UTF-8"));
  //考虑到编码及大小写问题, 还有转义. 取得上传文件后的一个详解路径.
  $uploadfiles = pic_save($_FILES["Filedata"], $_POST['albumid'], addslashes(siconv(urldecode($_POST['title']), $_SC['charset'], "UTF-8")));
 }
 
 //根据我的分析, 以下内容在图片上传时没用, 不知头像上传会否用到.
 $proid = $_POST['proid'];
 $uploadResponse = true;
 $albumid = 0;
 //判断一下上传文件, 及上传文件数组.
 if($uploadfiles && is_array($uploadfiles)) {
  $status = "success";  //上传完成
  $albumid = $uploadfiles['albumid'];  // 上传的分类id
 } else {
  $status = "failure"; //这就是上传失败了.
 }
 
 //这是我自己加上去的, 估计uchome也会感激我.
 exit();
}
// 时间
$newalbumname = sgmdate('Ymd');

//引入模板
include template("do_swfupload");

//输出xml, swf配置需要.
$outxml = "<?xml version="1.0" encoding="UTF-8"?>n";
$outxml .= siconv(ob_get_contents(), 'UTF-8');
obclean();
@header("Expires: -1");
@header("Cache-Control: no-store, private, post-check=0, pre-check=0, max-age=0", FALSE);
@header("Pragma: no-cache");
@header("Content-type: application/xml; charset=utf-8");
echo $outxml;

// 配置文件具体导出什么内容呢? 请访问这个网址.
//http://u.discuz.net/home/do.php?ac=swfupload&op=config
?>

本站推荐出百度、谷歌关键词排名在线查询哦,

查询地址:

http://zz.111cn.net/keyword/

工具说明

其中关键词排名的关键词自动从你网页代码中的Keywords提取!

系统会自动提供网站关键字进行google,baidu查询1-100名以前的关键哦。

网页编码:gb2312
Meta信息中关键词设置例:<meta name="keywords" content="chaxun.la,查询啦,网站综合信息查询工具,站长工具源码,站长工具" />
你Meta信息关键词设置为:<meta name="keywords" content="矢量素材,网页模板,免费模板,素材,QQ表情,源码下载" />
关键词 百度排名 谷歌排名 详细信息
矢量素材
排名100以外
排名100以外
php?u=down.111cn.net&q=矢量素材&action=baidu" target="_blank">百度 谷歌
网页模板
排名100以外
71,
百度 谷歌
免费模板
排名100以外
排名100以外
百度 谷歌
素材
排名100以外
排名100以外
百度 谷歌
QQ表情
排名100以外
排名100以外
百度 谷歌
源码下载
排名100以外
68,
百度 谷歌

本网站提供站长工具,alexa信息查询,alexa详细查询,alexa信息查询工具,alexa详细查询工具等信息,

查询地址:http://alexa.111cn.net/

查询效果

网站综合Alexa信息  (以下信息获取自www.alexa.com xml接口)

 
站点名称 zhong guo W E B di yi zhan 收录日期   网站语言 zh-CN
网站域名 111cn.net 编码方式 gb2312 网站站长 dengxianhong
综合排名 19,413 访问速度 817毫秒,比88%的网站快! 电子信箱 mailangel123@163.com
排名变化 -19,468alexa流量排名在线查询 反向链接 87 联系电话  
详细地址 China Chang Sha shi, Hunan 410001 Hu Nan chang sha , Chang Sha shi, Hunan 410001
网站简介  
DMOZ目录  


Alexa 排名详细信息
当日排名 排名变化趋势 一周平均排名 排名变化趋势 一月平均排名 排名变化趋势 三月平均排名 排名变化趋势
83,889 +72,872 alexa流量排名在线查询 13,155 -2,023 alexa流量排名在线查询 14,974 -2,618 alexa流量排名在线查询 19,413 -19,468 alexa流量排名在线查询
根据 ALEXA 统计数据估算网站 IP & PV 值,以下数据仅做参考之用、根据网站工具条用户比例不同会产生不同误差率
日均 IP 访问量 ≈90,000 日均 PV 浏览量 ≈144,000
Alexa 详细信息
  Reach
到访量
Pageviews
页面浏览量
Pageviews/User
每位访客浏览页数
Bounce %
跳出率
Time on Site
平均停留时间
Search %
流量源自搜索
引擎所占比例
昨天 0.003 -80% alexa流量排名在线查询 0.00003 -90% alexa流量排名在线查询 1 -50% alexa流量排名在线查询 - - - - - -
一周 0.015 +7% alexa流量排名在线查询 0.00025 +16% alexa流量排名在线查询 1.6 +8% alexa流量排名在线查询 74.6 +13% alexa流量排名在线查询 100.3 -2% alexa流量排名在线查询 48.6 -6% alexa流量排名在线查询
一月 0.0135 +20% alexa流量排名在线查询 0.000196 +20% alexa流量排名在线查询 1.43 -0.7% alexa流量排名在线查询 72.2 0% 94.7 0% 49.7 +4% alexa流量排名在线查询
三月 0.0099 +149% alexa流量排名在线查询 0.000154 +118% alexa流量排名在线查询 1.43 -12% alexa流量排名在线查询 73.2 +22% alexa流量排名在线查询 93.4 -26% alexa流量排名在线查询 48.4 +21% alexa流量排名在线查询



Alexa详细信息(以下信息采集自www.alexa.com)
其他国家/地区排名   访问国家/地区比
  • 1,560 psites/countries/CN">alexa流量排名在线查询  China
  •  
  • 98.4% China
  • 1.6% OTHER
  • 下属站点被访问比例   该站本月热门关键词   该站热门关键词
    111cn.net:

     

     
  • php implode
  • mysqli
  • jquery 手册
  • apache 别名
  • php in_array
  • php list
  • php setcookie
  • mysqli mysql
  • div padding
  • 弹出层
  •  
  • javascript+settimeout&p=gkey&r=site_site">javascript settimeout
  • mysqli
  • php foreach
  • php array
  • javascript
  • list
  • jquery
  • print
  • mysql
  • php list
  • php setcookie
  • window
  • div padding
  • dedecms 模板
  • php include
  • php urlencode
  • lightbox
  • apache
  • javascript confirm
  • php isset
  • 下载
  • smarty
  • animate
  • target
  • mysql 下载
  • lightbox jquery
  • echo
  • parent
  • 过滤器
  • google 收录 查询
  •   

    日均网站流量排名(Traffic Rank)走势图  (点击时间段查看相应时段曲线)
    两 年数据 六个月数据 三个月数据 一个月数据 一星期数据
    alexa流量排名在线查询

    js 可增加删除图片上传框js代码
    本款程序可以检测用户上传图片类型,大小,在上传之前,同时也可以增加多文件上传,就是不定文件多少,仿51空间那种文件上代码
    <!DOCTYPE html>
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
    <title>图片预览效果</title>
    <script src="CJL.0.1.min.js"></script>
    <script src="QuickUpload.js"></script>
    <script >

    var ImagePreview = function(file, img, options) {
     
     this.file = $$(file);//文件对象
     this.img = $$(img);//预览图片对象
     
     this._preload = null;//预载图片对象
     this._data = "";//图像数据
     this._upload = null;//remote模式使用的上传文件对象
     
     var opt = this._setOptions(options);
     
     this.action = opt.action;
     this.timeout = opt.timeout;
     this.ratio = opt.ratio;
     this.maxWidth = opt.maxWidth;
     this.maxHeight = opt.maxHeight;
     
     this.onCheck = opt.onCheck;
     this.onShow = opt.onShow;
     this.onErr = opt.onErr;
     
     //设置数据获取程序
     this._getData = this._getDataFun(opt.mode);
     //设置预览显示程序
     this._show = opt.mode !== "filter" ? this._simpleShow : this._filterShow;
    };
    //根据浏览器获取模式
    ImagePreview.MODE = $$B.ie7 || $$B.ie8 ? "filter" :
     $$B.firefox ? "domfile" :
     $$B.opera || $$B.chrome || $$B.safari ? "remote" : "simple";
    //透明图片
    ImagePreview.TRANSPARENT = $$B.ie7 || $$B.ie6 ?
     "mhtml:" + document.scripts[document.scripts.length - 1].getAttribute("src", 4) + "!blankImage" :
     "data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==";

    ImagePreview.prototype = {
      //设置默认属性
      _setOptions: function(options) {
        this.options = {//默认值
      mode:  ImagePreview.MODE,//预览模式
      ratio:  0,//自定义比例
      maxWidth: 0,//缩略图宽度
      maxHeight: 0,//缩略图高度
      onCheck: function(){},//预览检测时执行
      onShow:  function(){},//预览图片时执行
      onErr:  function(){},//预览错误时执行
      //以下在remote模式时有效
      action:  undefined,//设置action
      timeout: 0//设置超时(0为不设置)
        };
        return $$.extend(this.options, options || {});
      },
      //开始预览
      preview: function() {
     if ( this.file && false !== this.onCheck() ) {
      this._preview( this._getData() );
     }
      },
     
      //根据mode返回数据获取程序
      _getDataFun: function(mode) {
     switch (mode) {
      case "filter" :
       return this._filterData;
      case "domfile" :
       return this._domfileData;
      case "remote" :
       return this._remoteData;
      case "simple" :
      default :
       return this._simpleData;
     }
      },
      //滤镜数据获取程序
      _filterData: function() {
     this.file.select();
     try{
      return document.selection.createRange().text;
     } finally { document.selection.empty(); }
      },
      //domfile数据获取程序
      _domfileData: function() {
     return this.file.files[0].getAsDataURL();
      },
      //远程数据获取程序
      _remoteData: function() {
     this._setUpload();
     this._upload && this._upload.upload();
      },
      //一般数据获取程序
      _simpleData: function() {
     return this.file.value;
      },
     
      //设置remote模式的上传文件对象
      _setUpload: function() {
     if ( !this._upload && this.action !== undefined && typeof QuickUpload === "function" ) {
      var oThis = this;
      this._upload = new QuickUpload(this.file, {
       onReady: function(){
        this.action = oThis.action; this.timeout = oThis.timeout;
        var parameter = this.parameter;
        parameter.ratio = oThis.ratio;
        parameter.width = oThis.maxWidth;
        parameter.height = oThis.maxHeight;
       },
       onFinish: function(iframe){
        try{
         oThis._preview( iframe.contentWindow.document.body.innerHTML );
        }catch(e){ oThis._error("remote error"); }
       },
       onTimeout: function(){ oThis._error("timeout error"); }
      });
     }
      },
     
      //预览程序
      _preview: function(data) {
     //空值或相同的值不执行显示
     if ( !!data && data !== this._data ) {
      this._data = data; this._show();
     }
      },
     
      //设置一般预载图片对象
      _simplePreload: function() {
     if ( !this._preload ) {
      var preload = this._preload = new Image(), oThis = this;
      preload.onload = function(){ oThis._imgShow( oThis._data, this.width, this.height ); };
      preload.onerror = function(){ oThis._error(); };
     }
      },
      //一般显示
      _simpleShow: function() {
     this._simplePreload();
     this._preload.src = this._data;
      },
     
      //设置滤镜预载图片对象
      _filterPreload: function() {
     if ( !this._preload ) {
      var preload = this._preload = document.createElement("div");
      //隐藏并设置滤镜
      $$D.setStyle( preload, {
       width: "1px", height: "1px",
       visibility: "hidden", position: "absolute", left: "-9999px", top: "-9999px",
       filter: "progid:DXImageTransform.Microsoft.AlphaImageLoader(sizingMethod='image')"
      });
      //插入body
      var body = document.body; body.insertBefore( preload, body.childNodes[0] );
     }
      },
      //滤镜显示
      _filterShow: function() {
     this._filterPreload();
     var preload = this._preload,
      data = this._data.replace(/[)'"%]/g, function(s){ return escape(escape(s)); });
     try{
      preload.filters.item("DXImageTransform.Microsoft.AlphaImageLoader").src = data;
     }catch(e){ this._error("filter error"); return; }
     //设置滤镜并显示
     this.img.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(sizingMethod='scale',src="" + data + "")";
     this._imgShow( ImagePreview.TRANSPARENT, preload.offsetWidth, preload.offsetHeight );
      },
     
      //显示预览
      _imgShow: function(src, width, height) {
     var img = this.img, style = img.style,
      ratio = Math.max( 0, this.ratio ) || Math.min( 1,
        Math.max( 0, this.maxWidth ) / width  || 1,
        Math.max( 0, this.maxHeight ) / height || 1
       );
     //设置预览尺寸
     style.width = Math.round( width * ratio ) + "px";
     style.height = Math.round( height * ratio ) + "px";
     //设置src
     img.src = src;
     this.onShow();
      },
     
      //销毁程序
      dispose: function() {
     //销毁上传文件对象
     if ( this._upload ) {
      this._upload.dispose(); this._upload = null;
     }
     //销毁预载图片对象
     if ( this._preload ) {
      var preload = this._preload, parent = preload.parentNode;
      this._preload = preload.onload = preload.onerror = null;
      parent && parent.removeChild(preload);
     }
     //销毁相关对象
     this.file = this.img = null;
      },
      //出错
      _error: function(err) {
     this.onErr(err);
      }
    }
    </script>
    </head>
    <body>
    <style>
    .perview {width:600px;background:#fff;font-size:12px; border-collapse:collapse;}
    .perview td, .perview th {padding:5px;border:1px solid #ccc;}
    .perview th {background-color:#f0f0f0; height:20px;}
    .perview a:link, .perview a:visited, .perview a:hover, .perview a:active {color:#00F;}
    .perview table{ width:100%;border-collapse:collapse;}
    </style>
    <table border="0" class="perview">
     <tr>
       <th>选择文件</th>
       <th width="50%">预览图</th>
      </tr>
      <tr>
       <td height="200"><input id="idFile" name="pic" type="file" /></td>
       <td align="center"><img id="idImg" /></td>
      </tr>
     </tbody>
    </table>
    <script>

    var ip = new ImagePreview( $$("idFile"), $$("idImg"), {
     maxWidth: 200, maxHeight: 200, action: "ImagePreview.ashx"
    });
    ip.img.src = ImagePreview.TRANSPARENT;
    ip.file.onchange = function(){ ip.preview(); };

    </script>
    <br />
    <style>
    /*file样式*/
    #idPicFile {
     width:80px;height:20px;overflow:hidden;position:relative;
     background:url(http://www.cnblogs.com/images/cnblogs_com/cloudgamer/169629/o_addfile.jpg) center no-repeat;
    }
    #idPicFile input {
     font-size:20px;cursor:pointer;
     position:absolute;right:0;bottom:0;
     filter:alpha(opacity=0);opacity:0;
     outline:none;hide-focus:expression(this.hideFocus=true);
    }
    </style>
    <table class="perview">
     <tr>
      <th align="right"> 选择图片: </th>
      <td width="75%"> <div id="idPicFile"> </div> </td>
     </tr>
     <tr>
      <td colspan="2"><table>
        <thead>
         <tr>
          <th> 文件路径 </th>
          <th width="30%"> 预览图 </th>
          <th width="20%"> 操作 </th>
         </tr>
        </thead>
        <tbody id="idPicList">
         <tr>
          <td></td>
          <td align="center"></td>
          <td align="center"><a href="#">移除</a></td>
         </tr>
        </tbody>
       </table></td>
     </tr>
    </table>
    <script>

    var table = $$("idPicList"), model = table.removeChild(table.rows[0]);

    function AddPreview(){
     var file = document.createElement("input"),
      img = document.createElement("img"),
      ip = new ImagePreview( file, img, {
        maxWidth: 150,
        maxHeight: 100,
        action:  "ImagePreview.ashx",
        onErr:  function(){ alert("载入预览出错!"); ResetFile(file); },
        onCheck: CheckPreview,
        onShow:  ShowPreview
       });
     file.type = "file"; file.name = "pic";
     file.onchange = function(){ ip.preview(); };
     $$("idPicFile").appendChild(file);
    }

    //检测程序
    var exts = "jpg|gif|bmp", paths = "|";
    function CheckPreview(){
     var value = this.file.value, check = true;
     if ( !value ) {
      check = false; alert("请先选择文件!");
     } else if ( !RegExp( ".(?:" + exts + ")$$", "i" ).test(value) ) {
      check = false; alert("只能上传以下类型:" + exts);
     } else if ( paths.indexOf( "|" + value + "|" ) >= 0 ) {
      check = false; alert("已经有相同文件!");
     }
     check || ResetFile(this.file);
     return check;
    }

    //显示预览
    function ShowPreview(){
     var row = table.appendChild(model.cloneNode(true)),
      file = this.file, value = file.value, oThis = this;
     
     row.appendChild(file).style.display = "none";
     row.cells[0].innerHTML = value;
     row.cells[1].appendChild(this.img);
     
     row.getElementsByTagName("a")[0].onclick = function(){
      oThis.dispose(); table.removeChild(row);
      paths = paths.replace(value, ""); return false;
     };
     
     paths += value + "|";
     AddPreview();
    }

    AddPreview();


    function ResetFile(file){
     file.value = "";//ff chrome safari
     if ( file.value ) {
      if ( $$B.ie ) {//ie
       with(file.parentNode.insertBefore(document.createElement('form'), file)){
        appendChild(file); reset(); removeNode(false);
       }
      } else {//opera
       file.type = "text"; file.type = "file";
      }
     }
    }

    </script>
    </body>
    </html>

    [!--infotagslink--]

    相关文章

    • PHP正则表达式取双引号内的内容

      取双引号内的内容我们如果一个字符串中只有一个可以使用explode来获得,但如果有多个需要使用正则表达式来提取了,具体的例子如下。 写程序的时候总结一点经验,如何只...2016-11-25
    • Django def clean()函数对表单中的数据进行验证操作

      这篇文章主要介绍了Django def clean()函数对表单中的数据进行验证操作,具有很好的参考价值,希望对大家有所帮助。一起跟随小编过来看看吧...2020-07-09
    • PHP正则表达式之捕获组与非捕获组

      今天遇到一个正则匹配的问题,忽然翻到有捕获组的概念,手册上也是一略而过,百度时无意翻到C#和Java中有对正则捕获组的特殊用法,搜索关键词有PHP时竟然没有相关内容,自己试了一下,发现在PHP中也是可行的,于是总结一下,分享的同...2015-11-08
    • php 验证只能输入汉字、英语、数字的正则表达式

      正则表达式是一门非常有用的并且进行模糊判断的一个功能了,我们下面来看通过正则来验证输入汉字、英语、数字,具体如下。 收藏了正则表达式。可以验证只能输入数...2016-11-25
    • JavaScript实现密码框输入验证

      这篇文章主要为大家详细介绍了JavaScript实现密码框输入验证,文中示例代码介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们可以参考一下...2021-10-01
    • java正则表达式判断前端参数修改表中另一个字段的值

      这篇文章主要介绍了java正则表达式判断前端参数修改表中另一个字段的值,需要的朋友可以参考下...2021-05-07
    • 常用的日期时间正则表达式

      常用的日期时间正则表达式 下面收藏了大量的日期时间正则匹配函数,包括分钟,时间与秒都能达到。 正则表达式 (?n:^(?=d)((?<day>31(?!(.0?[2469]|11))|30(?!.0?2)|29(...2016-11-25
    • PHP正则表达式匹配验证提取网址URL实例总结

      网址规则是可寻的,所以我们可以使用正则表达式来提取字符串中的url地址了,下面一起来看看小编整理的几个PHP正则表达式匹配验证提取网址URL实例. 匹配网址 URL 的...2016-11-25
    • Nest.js 授权验证的方法示例

      这篇文章主要介绍了Nest.js 授权验证的方法示例,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧...2021-02-22
    • el-table树形表格表单验证(列表生成序号)

      这篇文章主要介绍了el-table树形表格表单验证(列表生成序号),文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧...2020-06-01
    • 正则表达式中两个反斜杠的匹配规则详解

      这篇文章主要介绍了正则表达式中两个反斜杠的匹配规则,本文给大家介绍的非常详细,对大家的学习或工作具有一定的参考借鉴价值,需要的朋友可以参考下...2021-05-07
    • selenium 反爬虫之跳过淘宝滑块验证功能的实现代码

      这篇文章主要介绍了selenium 反爬虫之跳过淘宝滑块验证功能,本文给大家介绍的非常详细,对大家的学习或工作具有一定的参考借鉴价值,需要的朋友可以参考下...2020-08-27
    • JS中使用正则表达式g模式和非g模式的区别

      这篇文章给大家详细介绍了JS中使用正则表达式g模式和非g模式的区别,非常不错,具有参考借鉴价值,需要的朋友参考下吧...2017-04-03
    • JavaScript利用正则表达式替换字符串中的内容

      本文主要介绍了JavaScript利用正则表达式替换字符串中内容的具体实现方法,并做了简要注释,便于理解。具有一定的参考价值,需要的朋友可以看下...2017-01-09
    • C#正则表达式使用方法示例

      这篇文章主要介绍了C#正则表达式使用方法,大家参考使用...2020-06-25
    • vue element table中自定义一些input的验证操作

      这篇文章主要介绍了vue element table中自定义一些input的验证操作,具有很好的参考价值,希望对大家有所帮助。一起跟随小编过来看看吧...2020-07-18
    • js canvas实现滑块验证

      这篇文章主要为大家详细介绍了js canvas实现滑块验证,文中示例代码介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们可以参考一下...2021-03-14
    • vue实现表单验证小功能

      这篇文章主要为大家详细介绍了vue实现表单验证小功能,文中示例代码介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们可以参考一下...2021-09-29
    • 常用C#正则表达式汇总介绍

      c#正则表达式,用于字符串处理、表单验证等场合,实用高效。现将一些常用的表达式收集于此,以备不时之需。...2020-06-25
    • 一文秒懂python正则表达式常用函数

      这篇文章主要介绍了python正则表达式常用函数及使用方法,本文给大家介绍的非常详细,对大家的学习或工作具有一定的参考借鉴价值,需要的朋友可以参考下...2021-05-07