Is there any way to detect a exist file in HTML?

Viewed 17

Why i cant use fs.existsSync in html <script!>? Here is my code

<html>
    <head>
        <p style="text-align:center">My website</p>
    </head>
    <body style="text-align:center;">
    <div>
        <a>Information: </a>
        <a id="infotext">no info</a>
    </div>
        <a id="myspan"> Name </a>
        <input name="growid" type="text" maxlength="512" id="growid" class="growid"/>
    <div>
        <button onclick="gooo()">Request</button>
    </div>
    </body>
    <script>
    const fs = require("fs")
    function setInfoText(text) {
        document.getElementById("infotext").innerHTML= text;
    }
    // gooo button
    function gooo() {
    let name = document.getElementById("growid").value
        if (fs.existsSync(`./db/${name}.json`)) {
            setInfoText("Welcome! youre this website member");
        } else {
            setInfoText("I dont know who are you, youre not registered");
        }
    }
    </script>
</html>
  • Or is Filesystem doesnt work in script html? Sorry iam new...
0 Answers
Related