js实现点击头像选择图片后立刻显示更换后的图片:
imgselect是控件的id
imgshow是的id
代码如下
function user_imgchanged(imgselect, imgshow) {
var img = document.getElementById(imgshow);
var url = null;
var fileObj = document.getElementById(imgselect).files[0];
if (window.createObjcectURL != undefined) {
url = window.createOjcectURL(fileObj);
} else if (window.URL != undefined) {
url = window.URL.createObjectURL(fileObj);
} else if (window.webkitURL != undefined) {
url = window.webkitURL.createObjectURL(fileObj);
}
img.src = url;
}