【发布时间】:2011-10-30 22:30:49
【问题描述】:
我想将拖放的图像保存到 html5 文件系统中。问题是我不知道如何使用文件 api 将二进制数据写入文件系统。以下是我的部分代码:
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);
我故意省略了一些代码,例如文件系统和文件创建。我只需要保存二进制数据的帮助。
谢谢。
【问题讨论】:
标签: html filesystems binary-data