將下列程式碼加入 component.ts 粗體字為錯誤地方, 再麻煩先進教導
readfiles(files) {
for (var i = 0; i < files.length; i++) {
(document.getElementById(“fileDragName”)).value = files[i].name
(document.getElementById(“fileDragSize”)).value = files[i].size
(document.getElementById(“fileDragType”)).value = files[i].type
let reader = new FileReader();
reader.onload = function(event) {
(document.getElementById(“fileDragData”)).value = event.target.result;}
reader.readAsDataURL(files[i]);
}
}
holder = (document.getElementById(“holder”));
holder.ondragover = function () { this.className = ‘hover’; return false; };
holder.ondragend = function () { this.className = ‘’; return false; };
holder.ondrop = function (e) {
this.className = ‘’;
e.preventDefault();
this.readfiles(e.dataTransfer.files);
}