js 获取input file路径改变图像地址

已转至:http://blog.csdn.net/sangjinchao/article/details/52250318

html代码

<img id="newImage" alt="100x100" src="__PUBLIC__/img/1.jpg" class="img-circle" width="100px" height="100px" >

<input id="image" type='file' name='myFile' size='15' onchange="showPicture(this)"/>

js代码

function showPicture(imgFile){
// alert(window.URL.createObjectURL(imgFile.files[0]));
/*获取上传文件的路径*/
document.getElementById("newImage").src = window.URL.createObjectURL(imgFile.files[0]);
}

原文地址:https://www.cnblogs.com/lurensang/p/5787278.html