[英]Download file from server folder to client pc
How can you download a file (.mp3) from a publicly accessible folder on the server to the clients pc? 如何从服务器上可公开访问的文件夹中将文件(.mp3)下载到客户端PC?
I have tried: 我努力了:
let url = "\\public\\test.mp3";
let xhr = new XMLHttpRequest();
xhr.responseType = 'blob';
xhr.onload = function() {
var a = document.createElement('a');
// xhr.response is a blob
a.href = window.URL.createObjectURL(xhr.response);
a.download = 'test.mp3';
a.style.display = 'none';
document.body.appendChild(a);
a.click();
};
xhr.open('GET', url);
xhr.send();
But this just downloads the file with 15KB not the entire thing 但这只是下载15KB的文件而不是全部
只需将用户导航到mp3文件:
window.location.href = '\\\\public\\\\test.mp3';
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.