HTML5 is one of the powerful is to allow web applications to apply for temporary or permanent space (Quota) data can be stored here even file operations.
code is as follows:


window. RequestFileSystem=Windows. RequestFileSystem | | window. WebkitRequestFileSystem;//file system request id window.
resolveLocalFileSystemURL=Windows. ResolveLocalFileSystemURL | | window. WebkitResolveLocalFileSystemURL;//根据URL取得文件的读取权限

得到系统的权限后就可以向浏览器申请空间

代码如下:


window.requestFileSystem(window.PERSISTENT,//persistent(永久) or temporary(临时)
1024*1024,//1M

代码如下:


function>

代码如下:


void queryUsageAndQuota(
in DOMString url,
in EntryCallback successCallback,
in optional ErrorCallback errorCallback
);

这个API可以查询当前web的空间情况,如果成功的话就会调用successCallback回调函数 并把已用空间和全部空间作为参数传入方法中。如果失败则调去errorCallback。

代码如下:


window.webkitStorageInfo.queryUsageAndQuota(webkitStorageInfo.PERSISTENT,
function(used, remaining){
if(remaining==""){
console.log("未申请空间。");
}else{
console.log("已使用空间"+used);
console.log("全部空间"+remaining);
}
},
errorHandler);

<P>
we can judge the remaining parameters to judge whether have applied for space, if no request, it returns the previous step to apply for the space. If have space, you will need to get the space with documents, to manipulate the data.
code is as follows:


void resolveLocalFileSystemURL (
in DOMString url,
in EntryCallback successCallback,
in optional ErrorCallback ErrorCallback
);

here you can read the native storage of data

code is as follows:


var="filesystem: http://" url + Windows. The location. The host + "/persistent catwrite_documents/";
window.resolveLocalFileSystemURL(url,function(fileEntry){
console.log(fileEntry);
var dirReader=fileEntry.createReader();
var readEntries=function(){
dirReader.readEntries(function(results){
if(!results.length){
create_file_title("默认文件", "");
console.log("没有文件!");
}else{
console.log("读取到" + results.length + "个文件");
for(var i=0; i console.log(results[i].name);
getFileContentByName(fileEntry, results[i].name);
}
}
},errorHandler);
};
readEntries();
},errorHandler);


This concludes the body part