function setImagePreviews() { var docObj = document.getElementById("inputFile"); if (docObj.files && docObj.files[0]) { var imgFile = docObj.files[0]; var imgThumb = document.getElementById("img"); imgThumb.src = window.URL.createObjectURL(docObj.files[0]); } else { alert("请使用谷歌浏览器"); } }