首页 > Web开发 > 详细

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

时间:2016-08-19 14:41:31      阅读:142      评论:0      收藏:0      [点我收藏+]

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

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

原文:http://www.cnblogs.com/lurensang/p/5787278.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!