私にはテーブルがあります。各行には1つの画像アップロード用のセルがあります。私はプレビューを表示したい。それは私にエラーを与えて実行している間アップロード前のプレビュー画像
var cell8 = row.insertCell(6);
var t8 = document.createElement("input");
t8.type = "file";
t8.id = "img" + index;
t8.name = "img" + index;
var a = document.getElementById('blah_img' + index + '');
a.src = window.URL.createObjectURL(this.files[0]);
t8.onchange = a.src;
cell8.appendChild(t8);
var oImg = document.createElement("img");
oImg.setAttribute('src', 'noimg.png');
oImg.setAttribute('alt', 'your image');
oImg.setAttribute('height', '100');
oImg.setAttribute('width', '100');
oImg.id = "blah_img" + index;
cell8.appendChild(oImg);
:このために私は以下のコードを書いた
Uncaught TypeError: Cannot read property '0' of undefined.
は私のコードで何が悪いのでしょうか?助けてください。
どのラインがそのエラーを与えていますか? –
window.URL.createObjectURL(this.files [0]) – Rose
「this」は何かを指すことを意図していますか? 't8.files [0]'を試してください –