我想将放置的图像保存到html5文件系统。问题是我不知道如何用文件API将二进制数据写入文件系统。以下是我的部分代码:html5 - 如何将二进制数据保存到html5文件系统
var reader = new FileReader();
reader.onloadend = function(e)
{
var data = e.target.result;
// Open File System code (Codes Omitted)
// Create file (Codes Omitted)
fileEntry.createWriter(function(fileWriter)
{
// This is the problem, the file is create, something is written to the file
// because the size is exact same with the dragged file (image). But when i
// try to view the file (image), it displays nothing.
var bb = new WebKitBlobBuilder
bb.append(data);
fileWriter.write(bb.getBlob(""));
}
}
reader.readAsBinaryString(cur_file);
我故意遗漏了一些代码,如文件系统和文件创建。我只需要帮助保存二进制数据。
谢谢。
2011-10-30
Kennedy