私は過去2日間試しています。私はファイルのアップロードと2つのテキストボックスを持って、すべてが動作しており、データベースに格納されていますが、イメージはありません。テキストボックスのデータはインデックス付きのdbに格納されていますが、画像はインデックス付きのdbに格納されていません。image[]
の空の配列として表示されています。これは私のjavascriptのadd関数ですどのようにインデックス付きのデータベースで画像付きテキストボックスからデータをアップロードする
function add() {
var a = document.getElementById("userfile");
var b = a.files[0];
var request = db.transaction(["todostore"], "readwrite")
.objectStore("todostore")
.add({
timestamp: "KP" + (new Date()).getTime(),
todo: $("#todo").val(),
price:$("#toprice").val(),
image:b
});
request.onsuccess = function(event) {
alert($("#todo").val() + " has been added to your database.");
$("#todo").val("");
};
};
これはhtmlのコードです。私はエラーを特定できませんでした。
<label for="todo">To Do:</label>
<input id="todo" type="text">
<input id="toprice" type="text">
<input type="file" id="userfile" />
<button onclick="add()">Add</button>
https://hacks.mozilla.org/2012/02/storing-images-and-files-in-indexeddb/ – joaumg
また、http://stackoverflow.com/questions/10586006/store-an-image-file-in-indexeddb – joaumg
@joaumgこの機能で何が問題なのか教えてください。 –