function uploadImage (upload) {
//初始化文件
var file;
if(upload.files){
var len = upload.files.length
for (var i = 0;i<len;i++) {
file = upload.files[i];
var Reader = new FileReader();
Reader.readAsDataURL(file);
Reader.onload = function(){
$(upload).next(".pos-img").attr("src",Reader.result);
}
}
}else{
var pic = $(upload).next(".pos-img").get(0),
file = upload;
var ext=file.value.substring(file.value.lastIndexOf(".")+1).toLowerCase();
// gif在IE浏览器暂时无法显示
if(ext!='png'&&ext!='jpg'&&ext!='jpeg'){
alert("图片的格式必须为png或者jpg或者jpeg格式!");
return;
}
var isIE = navigator.userAgent.match(/MSIE/)!= null,
isIE6 = navigator.userAgent.match(/MSIE 6.0/)!= null;
if(isIE) {
file.select();
js 实现图片预览功能支持ie8
最新推荐文章于 2021-06-05 02:27:09 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)