admin管理员组

文章数量:1201569

I am trying on Firefox,IE 9,Chrome and Opera the code below ,but the onInitFs(fs) function doesn't get called.if I add '()' to onInitFs in the window.requestFileSystem(window.PERSISTENT, 1024*1024, onInitFs, errorHandler) that function get called but fs is null ? Does anybody know how to solve this problem?I try on windows 7.I'll appreciate very much your help.

<!DOCTYPE HTML>
`<html>
    <head>  
    <script>
        function errorHandler(e){
            alert("errorrrr");
        }
        function onInitFs(fs){
        alert("onInitFs");
        }
        function readClick(){
                 if (window.webkitRequestFileSystem) {
                     window.webkitRequestFileSystem(window.PERSISTENT, 1024*1024,onInitFs,errorHandler);
                } 
                 else {
                    window.requestFileSystem(window.PERSISTENT, 1024*1024, onInitFs, errorHandler);
                }

            alert("read finishsssss");
        }
        </script>
    </head>
<body>
<input type="button" value="Read dir" onclick="readClick()">
    <ul id="filelist"></ul>
</body>
</html>

I am trying on Firefox,IE 9,Chrome and Opera the code below ,but the onInitFs(fs) function doesn't get called.if I add '()' to onInitFs in the window.requestFileSystem(window.PERSISTENT, 1024*1024, onInitFs, errorHandler) that function get called but fs is null ? Does anybody know how to solve this problem?I try on windows 7.I'll appreciate very much your help.

<!DOCTYPE HTML>
`<html>
    <head>  
    <script>
        function errorHandler(e){
            alert("errorrrr");
        }
        function onInitFs(fs){
        alert("onInitFs");
        }
        function readClick(){
                 if (window.webkitRequestFileSystem) {
                     window.webkitRequestFileSystem(window.PERSISTENT, 1024*1024,onInitFs,errorHandler);
                } 
                 else {
                    window.requestFileSystem(window.PERSISTENT, 1024*1024, onInitFs, errorHandler);
                }

            alert("read finishsssss");
        }
        </script>
    </head>
<body>
<input type="button" value="Read dir" onclick="readClick()">
    <ul id="filelist"></ul>
</body>
</html>
Share Improve this question edited Mar 29, 2012 at 11:11 Rob W 349k87 gold badges807 silver badges682 bronze badges asked Jul 23, 2011 at 20:19 Tony2Tony2 1111 gold badge1 silver badge4 bronze badges 1
  • Related: stackoverflow.com/questions/19802032/… – Pacerier Commented Jan 31, 2017 at 14:47
Add a comment  | 

2 Answers 2

Reset to default 14

Only chrome supports requestFileSystem as the webkitRequestFileSystem version.

None of the other browsers (FF6, IE9, Op11) support this

Disregarding the security issue that you cannot "browse" local files with a website, your question should be answered:

When requesting a PERSISTENT filesystem you have to request a quota in first. Try that instead:

window.storageInfo.requestQuota(PERSISTENT, 1024*1024, 
    function(grantedBytes) {
        window.requestFileSystem(window.PERSISTENT, grantedBytes, onInitFs, errorHandler);
    }, 
    errorHandler
);

本文标签: javascriptwindowrequestFileSystem not workingStack Overflow