<img id="img01" src="" alt="" />
function getFileUrl(file) {
var url;
var agent = navigator.userAgent;
if (agent.indexOf("MSIE") >= 1 || agent.indexOf("NET")!=-1) {
url = window.URL.createObjectURL(file);
} else if (agent.indexOf("Firefox") > 0) {
url = window.URL.createObjectURL(file);
} else if (agent.indexOf("Chrome") > 0) {
url =window.webkitURL.createObjectURL(file);
}
return url;
}
var file=document.getElementById('file').files[0];
var url = getFileUrl(file);
var imgObj = new Image();
imgObj.src = url;
imgObj.onload = function () {
document.getElementById('img01').src=url;
}