File size: 1,196 Bytes
b4af4fe
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>Triflix Realtime Backup</title>
  <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet">
</head>
<body class="bg-light">
<div class="container py-5">
  <h1 class="mb-4">Upload a File for Realtime Backup</h1>
  <form id="uploadForm" enctype="multipart/form-data">
    <div class="mb-3">
      <input class="form-control" type="file" name="file" required>
    </div>
    <button type="submit" class="btn btn-primary">Upload & Push</button>
  </form>
  <div id="status" class="mt-3"></div>
</div>

<script>
document.getElementById('uploadForm').addEventListener('submit', async (e) => {
    e.preventDefault();
    const formData = new FormData(e.target);
    const statusDiv = document.getElementById('status');
    try {
        const res = await fetch('/upload', { method: 'POST', body: formData });
        const json = await res.json();
        statusDiv.innerText = json.status + ": " + json.path;
    } catch(err) {
        statusDiv.innerText = "Error: " + err;
    }
});
</script>
</body>
</html>