时间:2020-11-14 12:04:52 | 栏目:JavaScript代码 | 点击:次
<img id="img1" src=""/> <script> function fileChange(obj) { var url = obj.value url = "file:///" + url.replace("\\",'/'); alert(url); document.getElementById("img1").src= url; } </script> <input type="file" onchange="fileChange(this);" />
关键是:url = "file:///" + url.replace("\\",'/');