<!DOCTYPE HTML>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1, maximum-scale=1, user-scalable=no" />
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-status-bar-style" content="black" />
<meta content="telephone=no" name="format-detection" />
<script type="text/javascript" src="js/jquery-2.1.4.min.js"></script>
<title>拍照</title>
<style>
input{width:200px;height:200px; 若不想要input显示的文本内容,可以直接设置input透明opacity:0;}
#img{width:200px;height:200px;}
</style>
</head>
<body>
<input id="fileBtn" type="file" value="点我" onchange="upload('#fileBtn', '#img');" accept="image/*" capture="camera"/>
<img src="" id="img"/>
</body>
<script>
var upload = function(c, d){
var $c = document.querySelector(c),
$d = document.querySelector(d),
file = $c.files[0],
reader = new FileReader();
reader.readAsDataURL(file);
reader.onload = function(e){
$d.setAttribute("src", e.target.result);
};
};
</script>
</html>
web js实现照片拍照保存插件
猜你喜欢
转载自blog.csdn.net/xuehu837769474/article/details/81746434
今日推荐
周排行