非兼容ie,上传图片demo
2016-08-17 17:57
148 查看
</pre><pre name="code" class="html"><!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Document</title> <style> .upload { width: 114px; height: 143px; margin-right: 20px; } .upload .upload-body { background: #f6f7f8; -webkit-border-radius: 2px; -moz-border-radius: 2px; border-radius: 2px; text-align: center; width: 114px; height: 143px; position: relative; float: left; cursor: pointer; } .upload .upload-body a { display: block; cursor: pointer; text-decoration: underline; padding-top: 45px; padding-bottom: 25px; } .upload .upload-body span { display: block; color: #9c9c9c; cursor: pointer; } .upload .upload-body img { cursor: pointer; width: 100%; height: auto; position: absolute; top: 0; left: 0; right: 0; bottom: 0; margin: auto; display: none; } .upload .upload-body input { position: absolute; left: 0; width: 100%; top: 0; height: 100%; opacity: 0; filter: alpha(opacity=0); font-size: 500px; cursor: pointer; overflow: hidden; } </style> </head> <body> <div class="upload-wrap"> <div class="upload"> <div class="upload-body"> <a style="text-decoration: none;">+资质证书</a> <span>不超过500KB</span> <img src="" id="up-img" > <input type="file" id="touxiangfile" size="" name="touxiangfile" onchange="showPreview(this)"> </div> </div> </div> </body> <script src="jQuery v1.11.3.min.js"></script> <script> function showPreview(source){ var showImgUrl = "", file = source.files[0]; if(window.FileReader){ var fr = new FileReader(); fr.onloadend=function(e){ $("#up-img").prop("src",e.target.result).css("display","block"); showImgUrl = e.target.result } fr.readAsDataURL(file) } } </script> </html>
相关文章推荐
- javascript 客户端验证上传图片的大小(兼容IE和火狐)
- 上传图片预览 兼容IE和FF
- 兼容IE和FF的图片上传前预览js代码
- JavaScript实现本地图片上传预览功能(兼容IE、chrome、FF)
- javascript 上传 预览图片 兼容 谷歌 ie
- JS 预览上传图片,兼容IE、firefox等所有浏览器
- 图片上传预览(兼容火狐和IE)
- 图片上传预览 兼容ie67 8 9 及 FF
- JS实现图片上传时的本地预览,兼容IE和firefox谷歌
- 兼容IE、谷歌Chrome、火狐Firefox的图片上传预览功能
- 兼容IE、FF的图片上传预览
- 客户端验证上传图片的大小(兼容IE和火狐)
- 图片上传前预览(兼容FF和IE)
- 图片上传预览 兼容 IE 6 7 8 9 FF chrome opera等版本
- 兼容IE firefox 的图片上传预览
- Js下检查上传图片文件格式和大小的方法,兼容ie和火狐
- 多图片上传+图片预览,兼容所有浏览器 IE5/IE6/IE7/IE8/IE9/Chrome/Safari/Firefox/Opera/
- 多图片上传+图片预览,兼容所有浏览器 IE5/IE6/IE7/IE8/IE9/Chrome/Safari/Firefox/Opera/
- 兼容所有主流浏览器的图片上传本地预览(IE\FIREFOX\CHROME)
- 图片上传并预览(IE,火狐浏览器兼容问题)