Download the JS file, download the file to the browser sandbox and report an error

the code is as follows:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>
    <input name="download" id="download" />
    <button type="button" onclick="down()"></button>
</body>
    <script>
        function down() {
            window.webkitRequestFileSystem(Window.TEMPORARY,1024*1024,function(fs) {
                var fileEntry = fs.root.getFile("Test.txt",{create: true});
                var fileWriter = fileEntry.createWriter();
                fileWriter.seek(10);
                var blob = new Blob(["hello,the world"]);
                fileWriter.write(blob);
                console.log("Successfuly")
            },(err) => {
                console.log(err);
            });
        }

    </script>
</html>

browser error:

DOMException: It was determined that certain files are unsafe for access within a Web application, or that too many calls are being made on file resources.
Mar.01,2021

as far as I understand it, browsers do not allow js to manipulate local files directly, which is not safe. If you can access local files directly, what about the security of computing?

Menu