版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/zjl199303/article/details/78753594
<form action="">
<input type="file" accept="image/*" capture="camera" name="image"/>
<image src="" style="display:block;width:90%;"></image>
</form>
<!--拍照功能需要配合javascript使用-->
<script type="text/javascript">
var x = new FileReader;
document.forms[0].elements[0].onchange=function(){
x.readAsDataURL(this.files[0]);
}
x.onloadend=function(){
document.images[0].src=this.result;
alert(this.result)
}
<input type="file" accept="image/*" capture="camera" name="image"/>
<image src="" style="display:block;width:90%;"></image>
</form>
<!--拍照功能需要配合javascript使用-->
<script type="text/javascript">
var x = new FileReader;
document.forms[0].elements[0].onchange=function(){
x.readAsDataURL(this.files[0]);
}
x.onloadend=function(){
document.images[0].src=this.result;
alert(this.result)
}
</script>
效果: