-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
53 lines (48 loc) · 1.54 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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
<style>
body {
text-align: center;
height: 100vh;
width: 100vw;
margin: 0;
background: linear-gradient(to bottom right, #352482, #EA8F78);
}
#form {
zoom: 1.4;
}
</style>
</head>
<body>
<form method="POST" action="/upload" enctype="multipart/form-data" accept="image/*" id="form">
<input type="file" name="file" id="input-file">
<input type="submit" value="Submit">
</form>
<br/>
<img src="" id="image-preview" width="100vw" />
<script src="https://code.jquery.com/jquery-1.12.4.min.js" integrity="sha256-ZosEbRLbNQzLpnKIkEdrPv7lOy9C27hHQ+Xp8a4MxAQ="
crossorigin="anonymous"></script>
<script type="text/javascript">
function readImage(input)
{
let file = input.files && input.files[0];
if (file) {
let reader = new FileReader();
reader.onload = e => {
$('#image-preview').attr('src', e.target.result)
.css('min-width', '600px')
.css('max-height', '100vh')
.css('max-width', '100vw')
};
reader.readAsDataURL(file);
}
}
$("#input-file").change(function(){
readImage(this);
});
</script>
</body>
</html>