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]);
}


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM