[英]how can i convert .wav file from url to base64 in client-side javascript?
I have .wav file, placed on " http://yy.zz/1.wav ".我有 .wav 文件,放在“ http://yy.zz/1.wav ”上。 How can i fetch it with base64 encoding on client-side javascript?
如何在客户端 javascript 上使用 base64 编码获取它?
getFile('http://yy.zz/1.wav', (file) => {
console.log(getBase64File(file)); // profit
});
If the file is on the same domain or you have CORS enabled on the external site, you can do the following:如果文件在同一个域中,或者您在外部站点上启用了 CORS,您可以执行以下操作:
$.get("http://localhost/content/sound/hello.wav", function(file){
let fileInBase64Format = btoa(unescape(encodeURIComponent(file)));
console.log(fileInBase64Format);
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.