-
Notifications
You must be signed in to change notification settings - Fork 178
Expand file tree
/
Copy pathindex.html
More file actions
81 lines (71 loc) · 1.88 KB
/
index.html
File metadata and controls
81 lines (71 loc) · 1.88 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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
<!DOCTYPE html>
<html>
<head>
<title>✂️ rmbg</title>
<style>
body {
height: 100vh;
display: flex;
align-items: center;
justify-content: center;
text-align: center;
}
.drop-zone {
border: 2px dashed #ccc;
padding: 20px;
width: 80vw;
height: 80vh;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
cursor: pointer;
}
.drop-zone.dragover {
background-color: #f0f0f0;
}
</style>
</head>
<body>
<div id="dropZone" class="drop-zone">
<h1>rmbg</h1>
<form
id="uploadForm"
action="/"
method="post"
enctype="multipart/form-data"
>
<input id="fileInput" type="file" name="file" />
<input type="submit" value="rm" />
</form>
</div>
<script>
let dropZone = document.getElementById("dropZone");
let fileInput = document.getElementById("fileInput");
let uploadForm = document.getElementById("uploadForm");
dropZone.addEventListener("click", function () {
fileInput.click();
});
fileInput.addEventListener("change", function () {
if (fileInput.files.length > 0) {
uploadForm.submit();
}
});
dropZone.addEventListener("dragover", function (e) {
e.preventDefault();
this.classList.add("dragover");
});
dropZone.addEventListener("dragleave", function (e) {
this.classList.remove("dragover");
});
dropZone.addEventListener("drop", function (e) {
e.preventDefault();
e.stopPropagation();
this.classList.remove("dragover");
let file = e.dataTransfer.files[0];
fileInput.files = e.dataTransfer.files;
uploadForm.submit();
});
</script>
</body>
</html>