87,922
社区成员
发帖
与我相关
我的任务
分享
<img id="img" src="" />
<input id="chooseimg" type="file" onpropertychange="showpic()" />
function showpic(){
document.getElementById("img").scr = document.getElementById("chooseimg").value
<script type="text/javascript">
function $(id){
return document.getElementById(id);
}
function preview(file, img){
var nImg = document.createElement('img');
nImg.id = img.id;
nImg.src = 'file:\/\/\/' + file.value.replace(/\\/g, '\/');
img.parentNode.replaceChild(nImg, img);
}
</script>
<input type="file" onchange="preview(this, $('test'))"/><img id="test" />
<input id="chooseimg" type="file" onchange="showpic(this)" /><br>
<img id="img" src="" />
<script>
function showpic(t){
document.getElementById("img").src = t.value
}
</script>