您的位置:首页 > Web前端 > JavaScript

上传图片显示预览js代码

2015-06-08 08:15 393 查看
function change(el){

var objUrl = getObjectURL(el.files[0]) ;
console.log("objUrl = "+objUrl) ;

if (objUrl) {
$("#img0").attr("src", objUrl) ;
}
} ;

function getObjectURL(file) {

var url = null ;
if (window.createObjectURL!=undefined) { // basic
url = window.createObjectURL(file) ;
} else if (window.URL!=undefined) { // mozilla(firefox)
url = window.URL.createObjectURL(file) ;
} else if (window.webkitURL!=undefined) { // webkit or chrome
url = window.webkitURL.createObjectURL(file) ;
}
return url ;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  js 图片预览