<div class="upload_box">
<div id="preview">
<img id="imghead" src="0.jpg" width="190" height="130"/> <!--图片显示位置-->
</div>
<b>上传图片</b>
<input type="file" name="file" id="file" accept="image/*" onchange="imgChange(this);"/> <!--文件上传选择按钮-->
</div>
<script type="text/javascript">
// select image to display
function imgChange(obj) {
//Get the clicked text box
var file =document.getElementById("file");
var imgUrl =window.URL.createObjectURL(file.files[0]);
var img =document.getElementById('imghead');
img. setAttribute('src',imgUrl); // Modify the value of the src attribute of the img tag
};
</script>