save blob audio file on server with xmlhttprequest

大城市里の小女人 提交于 2019-12-23 03:47:10

问题


I'm working on an audio web application where you can play along with music and record yourself. I'm working with a recorder plugin and I'm trying to save what has been recorded in a folder on a server. I get a blob file from the plugin via this javascript code:

recorder.exportWAV(function(blob) {
        var xhr = new XMLHttpRequest();
        var url = '../../audio/recordings/test.wav';
        xhr.open('POST',url,true);
        xhr.onload = function(e) {
            if (this.status == 200) {
              console.log(this.responseText);
            }
          };
        xhr.send(blob); 
        },'audio/wav');

I have never worked with this before so I'm not sure if my code is right. But I get no errors my file is just not saved. I have been searching the internet for this and what I have found is that a lot of people use a php file as url. Why? What php file are they using?

Thanks!

来源:https://stackoverflow.com/questions/13658888/save-blob-audio-file-on-server-with-xmlhttprequest

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!