从javascript表下载存储在firebase数据库中的文件
我目前正在构建一个web应用程序,我对javascript非常陌生,我自己找不到解决方案。我目前正在从firebase数据库中拖动一些数据,并将它们显示在我的网站中。我的数据库看起来像这样 我正在使用html和javascript创建一个包含firebase数据库信息的表,并将其显示在我的网站上。html代码如下所示:从javascript表下载存储在firebase数据库中的文件,javascript,firebase,firebase-realtime-database,Javascript,Firebase,Firebase Realtime Database,我目前正在构建一个web应用程序,我对javascript非常陌生,我自己找不到解决方案。我目前正在从firebase数据库中拖动一些数据,并将它们显示在我的网站中。我的数据库看起来像这样 我正在使用html和javascript创建一个包含firebase数据库信息的表,并将其显示在我的网站上。html代码如下所示: <h3>Files List</h3> <table class="zui-table zui-tabl
<h3>Files List</h3>
<table class="zui-table zui-table-rounded" id="tbl_users_list" border="1">
<thead>
<tr>
<td>#ID</td>
<td>NAME</td>
<td>DATE</td>
<td>LINK</td>
</tr>
</thead>
</table>
</div>
var tblUsers = document.getElementById('tbl_users_list');
var databaseRef = firebase.database().ref('files/');
var rowIndex = 1;
databaseRef.once('value',function(snapshot){
snapshot.forEach(function(childsnapshot) {
var childKey = childsnapshot.key;
var childData = childsnapshot.val();
var row = tblUsers.insertRow(rowIndex);
var cellId = row.insertCell(0);
var cellName = row.insertCell(1);
var cellName2 = row.insertCell(2);
var button = row.insertCell(3);
var itd = document.createElement('input');
itd.setAttribute("type","button");
itd.setAttribute("value","Download");
cellId.appendChild(document.createTextNode(childKey));
cellName.appendChild(document.createTextNode(childData.name));
cellName2.appendChild(document.createTextNode(childData.created));
button.appendChild(itd);
rowIndex = rowIndex+1;
我的桌子看起来像这样
您需要检索url:
var childKey = childsnapshot.key;
var childData = childsnapshot.val();
var urls=childData.url;
然后单击按钮下载文件
var itd = document.createElement('input');
itd.onclick=function () {
window.open(childData.url);
};
window.open()
将根据以下内容下载文件:
您需要检索url:
var childKey = childsnapshot.key;
var childData = childsnapshot.val();
var urls=childData.url;
然后单击按钮下载文件
var itd = document.createElement('input');
itd.onclick=function () {
window.open(childData.url);
};
window.open()
将根据以下内容下载文件:
如果改用链接,则可以使用以下属性:
如果改用链接,则可以使用以下属性: