03 | <meta content= "text/html; charset=utf-8" http-equiv=content-type> |
04 | <meta name=author content= "Laruence(www.laruence.com)" > |
05 | <title>即时显示上传缩略图</title> |
07 | <body style= "text-align:center;" > |
09 | <div style= "width:200px; height:200px; border:1px solid #666;" ><img id= "img" style= "visibility:hidden;" height= "100%" width= "100%" ></div> |
10 | <div style= "margin-top:8px;" ><input id= "file" type= "file" onChange= "preivew(this,'img');" ></div> |
12 | <script language= "javascript" type= "text/javascript" > |
13 | var allowExt = [ 'jpg' , 'gif' , 'bmp' , 'png' , 'jpeg' ]; |
14 | var preivew = function (file, container){ |
16 | var pic = new Picture(file, document.getElementById(container)); |
22 | var Picture = function (file, container){ |
32 | if (window.navigator.userAgent.indexOf( "MSIE" )>=1){ |
34 | path = document.selection.createRange().text; |
35 | } else if (window.navigator.userAgent.indexOf( "Firefox" )>=1){ |
37 | path = file.files.item(0).getAsDataURL(); |
45 | ext = name.substr(name.lastIndexOf( "." ), name.length); |
46 | if (container.tagName.toLowerCase() != 'img' ){ |
48 | container.visibility = 'hidden' ; |
52 | container.style.visibility = 'visible' ; |
53 | height = container.height; |
54 | widht = container.widht; |
55 | size = container.fileSize; |
56 | this .get = function (name){ |
59 | this .isValid = function (){ |
60 | if (allowExt.indexOf(self.ext) !== -1){ |
|