$('.c_showFile').on('change',function(){
var c_showImg =this.files[0];
getObjectURL(c_showImg);
})
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);
}
$('.file').css("background-image","url("+url+")");
$('.file').css("background-size","100% 100%")
return url;
}
兼容性没有经过测试。需要用到的小伙伴请根据需求使用。