日期:2014-05-16 浏览次数:20519 次
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title>无标题页</title> </head> <body> <script> var version = parseFloat(navigator.appVersion.split("MSIE")[1]); function yulan(file,id) { if(file.value.indexOf(".jpg")<0 && file.value.indexOf(".jpeg")<0 && file.value.indexOf(".gif")<0 && file.value.indexOf(".png")<0 && file.value.indexOf(".JPG")<0 && file.value.indexOf(".JPEG")<0 && file.value.indexOf(".GIF")<0 && file.value.indexOf(".PNG")<0){ alert('您选择的不是图片文件'); return false; } if(navigator.userAgent.indexOf("Mozilla/5.")>-1){ document.getElementById(id).innerHTML = "<img src='"+file.files[0].getAsDataURL()+"' width='200px' height='180px'>"; CheckFileSize(file.files[0].getAsDataURL(),id); //if(CheckFileSize(file.files[0].getAsDataURL())>328)document.getElementById(id).getElementsByTagName('img')[0].style.width = "90px"; }else{ file.select(); var img = document.selection.createRange().text; document.getElementById(id).innerHTML = "<img src='"+img+"' width='200px' height='180px'>"; //if(CheckFileSize(file.value)>28) document.getElementById(id).getElementsByTagName('img')[0].style.width = "28px"; } } </script> <form name="form1" method="POST" enctype="multipart/form-data"> <input type="file" name="UpFile" size="46" onchange="yulan(this,'tu')"> <div id="tu"></div> </form> </body> </html>