在微信浏览器或其他移动端浏览器调起相机:
<input type="file" accept="image/*" value="上传" />
<input type="file" accept="image/*" capture="camera" value="上传" />
第一行可以调起相册、文件管理器、相机
第二行直接调起相机
下面是显示图片的一种实现方式
<input type="file" accept="image/*" value="上传" onchange="show(this)" />
<input type="file" accept="image/*" capture="camera" value="上传" onchange="show(this)" />
<script>
function show(el){
var imgsrc=window.URL.createObjectURL(el.files.item(0));
var img=new Image();
img.src=imgsrc;
document.body.appendChild(img);
};
</script>