我动态添加了输入文件标签,并通过传递两个参数来实现 onchange 方法,一个是 this(文件信息),另一个是 firestore 集合的文档 id。当文档 ID 以数字开头时,它会显示错误,但当文档 ID 以字母开头时,它会正常工作。
db.collection("DialogflowChatRoom").doc(userid).collection("Earlyyears").orderBy("Time")
.onSnapshot(function(querySnapshot) {
var store_row = document.createElement("questions");
var store;
$('#questions').empty();
querySnapshot.forEach(function(doc) {
store = document.createElement("div");
store.setAttribute("id", doc.id);
store.setAttribute("class", "card no-border");
// store.setAttribute("onClick", "select_user(this.id, '" + questionnumber + "', '" + time + "')");
store.innerHTML = `<div class="container1">
<img src="assets/images/image 209.png" alt="Avatar" class="right" style="width:100%;">
<input type="file" id="files" onchange="handleFileSelect(this,` + doc.id + `)" onclick="this.value=null;" accept="image/jpg, image/jpeg, image/png image/heic video/mp4" multiple>
</div>`;
store_row.append(store);
document.getElementById("questions").innerHTML = store_row.innerHTML;
});
});
function handleFileSelect(e,docid) {
console.log("values in handlefileselect are",e.files,docid.id)
var id = docid.id
}
湖上湖
相关分类