0
我想將放置的圖像保存到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);
我故意遺漏了一些代碼,如文件系統和文件創建。我只需要幫助保存二進制數據。
謝謝。