尝试在谷歌浏览器中使用HTML5文件API时获取FileError [英] Getting FileError when trying to use the HTML5 file api in google chrome
问题描述
我试图在chrome中使用文件系统API创建一个文件。最初我尝试了PERSISTENT存储,如下所示:
I was trying to create a file using the file system API in chrome. Initially I tried PERSISTENT storage as follows
window.requestFileSystem = window.requestFileSystem || window.webkitRequestFileSystem;
webkitStorageInfo.requestQuota(webkitStorageInfo.PERSISTENT, 1024*1024,
function(grantedBytes) {
window.requestFileSystem(webkitStorageInfo.PERSISTENT, grantedBytes, onInitFs,
errorHandler);
},
errorHandler);
最初工作正常。但现在当我尝试相同的代码给我以下错误:
It was working fine initially. But now when I try the same code is giving me the following error
NOT_SUPPORTED_ERR: DOM Exception 9
然后我尝试使用TEMPORARY文件存储如下
Then I tried TEMPORARY file storage as follows
window.requestFileSystem(TEMPORARY, 1024*1024, onInitFs, errorHandler);
这是给我一些代码为2的FileError,意思是安全错误。任何人都可以请帮我解决这些问题吗?
That is giving me some FileError with the code 2 which means Security Error. Can anyone please help me on these issues?
推荐答案
您是否尝试将代码放置在本地存储的页面中电脑并与Chrome运行?您是否添加了标志
Are you trying to place the code in a page that is stored on your local computer and run it with Chrome? Did you add the flag
--allow-file-access-from-files
?我偶然遇到了和你一样的错误,突然间我意识到我忘了添加这个标志来运行我的Chrome。
in your Chrome shortcut? I happened to encounter the same error as yours and suddenly I realized that I forgot to add this flag to run my chrome.
这篇关于尝试在谷歌浏览器中使用HTML5文件API时获取FileError的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!