File size: 1,229 Bytes
51a77b3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
<!-- templates/index.html -->
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>File2Link Uploader</title>
  <style>
    body { font-family: sans-serif; margin: 40px; }
    input[type="file"] { margin-bottom: 10px; }
    #response { margin-top: 20px; font-family: monospace; white-space: pre-wrap; }
  </style>
</head>
<body>
  <h2>πŸ“ Upload File to Internet Archive</h2>
  <form id="uploadForm">
    <input type="file" name="file" required>
    <br>
    <button type="submit">Upload</button>
  </form>

  <div id="response"></div>

  <script>
    const form = document.getElementById('uploadForm');
    const responseDiv = document.getElementById('response');

    form.onsubmit = async (e) => {
      e.preventDefault();
      const formData = new FormData(form);
      responseDiv.innerHTML = 'Uploading...';

      const res = await fetch('/upload', {
        method: 'POST',
        body: formData
      });

      const data = await res.json();
      if (data.success) {
        responseDiv.innerHTML = 'βœ… File uploaded!\n' + JSON.stringify(data, null, 2);
      } else {
        responseDiv.innerHTML = '❌ Error:\n' + JSON.stringify(data, null, 2);
      }
    };
  </script>
</body>
</html>