File size: 1,776 Bytes
6baac2b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
<!DOCTYPE html>
<html>
<head>
    <title>ZIP Extractor</title>
    <script>
        function uploadFile() {
            let formData = new FormData(document.getElementById("uploadForm"));
            let xhr = new XMLHttpRequest();

            xhr.open("POST", "/upload", true);
            xhr.onreadystatechange = function () {
                if (xhr.readyState == 4 && xhr.status == 200) {
                    document.getElementById("status").innerText = JSON.parse(xhr.responseText).message;
                }
            };
            xhr.send(formData);

            checkProgress();
        }

        function checkProgress() {
            let progressBar = document.getElementById("progressBar");
            let xhr = new XMLHttpRequest();

            xhr.open("GET", "/progress", true);
            xhr.onreadystatechange = function () {
                if (xhr.readyState == 4 && xhr.status == 200) {
                    let progress = JSON.parse(xhr.responseText).progress;
                    progressBar.value = progress;

                    if (progress < 100) {
                        setTimeout(checkProgress, 500);
                    }
                }
            };
            xhr.send();
        }
    </script>
</head>
<body>
    <h2>Upload a ZIP File</h2>
    <form id="uploadForm" method="post" enctype="multipart/form-data">
        <input type="file" name="zip_file" required>
        <br><br>
        <label for="extract_path">Extract to:</label>
        <input type="text" name="extract_path" placeholder="Enter folder path" required>
        <br><br>
        <button type="button" onclick="uploadFile()">Extract</button>
    </form>

    <progress id="progressBar" value="0" max="100"></progress>
    <p id="status"></p>
</body>
</html>