gpt4 book ai didi

php - PHP录制声音并使用progressbar上传php

转载 作者:行者123 更新时间:2023-12-03 01:12:13 26 4
gpt4 key购买 nike

我使用了链接上的代码来录制音频并上传到服务器。
我找到了一些上传进度条代码,但无法与此代码合并。
音频记录可能为30-40 mb,并且上传时间较长。
如何在下面添加此代码的上传状态?
https://blog.addpipe.com/using-recorder-js-to-capture-wav-audio-in-your-html5-web-site/

    var upload = document.createElement('a');
upload.href="#";
upload.innerHTML = "Upload";
upload.addEventListener("click", function(event){
var xhr=new XMLHttpRequest();
xhr.onload=function(e) {
if(this.readyState === 4) {
console.log("Server returned: ",e.target.responseText);
}
};

var fd=new FormData();
fd.append("audio_data",blob, filename);
fd.append("filename",blob, 'audiofile');
xhr.open("POST","upload.php",true);
xhr.send(fd);
alert('Uploaded');
}) ```

最佳答案

https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/upload

var xhr = new XMLHttpRequest();

xhr.upload.addEventListener('progress', function(event)
{
var progress = event.loaded / event.total * 100;

console.log('Progress: ' + progress);
});

关于php - PHP录制声音并使用progressbar上传php,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63424688/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com