forked from swimbird/HTML-Media-Capture-Demo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
57 lines (46 loc) · 1.56 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no">
<link href="./bootstrap/css/bootstrap.min.css" rel="stylesheet">
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script type="text/javascript" src="./js/jquery.upload-1.0.2.min.js"></script>
<title>HTML Media Capture Demo</title>
<script>
window.addEventListener("load", function(){
if (!window.File){
alert("Undefined File API");
return;
}
document.getElementById("imageFile").addEventListener("change", function(){
var reader = new FileReader();
reader.onload = function(event){
document.getElementById("image").src = reader.result;
}
var file = document.getElementById("imageFile").files[0];
reader.readAsDataURL(file);
}, true);
$("#upload").click(function() {
$("#imageFile").upload("post_file.php", function(data) {
if(data.status === "OK"){
console.log(data);
alert("OK");
}else{
alert(data.status);
}
}, "json");
});
}, true);
</script>
</head>
<body>
<form>
<input type="file" accept="image/*;capture=camera" id="imageFile" name="cameraData"/>
</form>
</body>
<img id="image"width="200" height="200"><br>
<button type="button" id="upload" class="">upload</button>
<br><br>
<a href="./show.php">show page</a>
</html>