forked from amitsin6h/html-canvas-screenshot
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.php
More file actions
executable file
·50 lines (41 loc) · 1.18 KB
/
Copy pathindex.php
File metadata and controls
executable file
·50 lines (41 loc) · 1.18 KB
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
<!DOCTYPE html>
<html>
<head>
<title>Screenshot using html2canvas</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script type="text/javascript" src="https://html2canvas.hertzen.com/dist/html2canvas.min.js"></script>
</head>
<body>
<h1 style="text-align: center;">Tutorial: How to take screenshot</h1>
<div id="capture" style="padding: 10px; background: #f5da55">
<h4 style="color: #000; ">Hello C-Sharpcorner User!!</h4>
</div>
<div style="margin-top: 50px; text-align: center;">
<button id="take_screenshoot">Take Screenshot</button>
</div>
<script type="text/javascript">
var dataURL = {};
$('#take_screenshoot').click(function(){
html2canvas(document.querySelector("#capture")).then(canvas => {
document.body.appendChild(canvas);
//console.log(canvas.toDataURL());
dataURL = canvas.toDataURL();
post_data(dataURL);
});
});
function post_data(imageURL){
//console.log(imageURL);
$.ajax({
url: "save_data.php",
type: "POST",
data: {image: imageURL},
dataType: "html",
success: function() {
alert('Success!!');
location.reload();
}
});
}
</script>
</body>
</html>