鍍金池/ 問答/HTML5  Python  HTML/ JS文件下載,將文件下載到瀏覽器沙箱報(bào)錯(cuò)

JS文件下載,將文件下載到瀏覽器沙箱報(bào)錯(cuò)

代碼如下:

<!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>

瀏覽器報(bào)錯(cuò):

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.
回答
編輯回答
來守候

按照我的理解的話,瀏覽器是不允許js直接操作本地文件的,這是不安全的。如果可以直接訪問本地文件,那么計(jì)算的安全呢?

2017年5月24日 23:29