我正在尝试Firefox,IE 9,Chrome和Opera下面的代码,但onInitFs(fs)函数没有被调用。如果我在window.requestFileSystem(window.PERSISTENT)中的onInitFs中添加'()' ,1024 * 1024,onInitFs,errorHandler)函数被调用但fs为空? 有没有人知道如何解决这个问题?我试试Windows 7.我非常感谢你的帮助。
<!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>
答案 0 :(得分:14)
只有Chrome支持requestFileSystem
作为webkitRequestFileSystem
版本。
其他浏览器(FF6,IE9,Op11)都不支持此
答案 1 :(得分:4)
忽略您无法通过网站“浏览”本地文件的安全问题,您的问题应该得到解答:
在请求PERSISTENT文件系统时,您必须先申请配额。 试试这个:
window.storageInfo.requestQuota(PERSISTENT, 1024*1024,
function(grantedBytes) {
window.requestFileSystem(window.PERSISTENT, grantedBytes, onInitFs, errorHandler);
},
errorHandler
);