Pass Blob through ajax to generate a file

前端 未结 2 569
青春惊慌失措
青春惊慌失措 2020-11-27 04:32

I\'m trying to capture audiorecorder (https://github.com/cwilso/AudioRecorder) and send the blob through Ajax a php file, which will receive the blob content and create the

2条回答
  •  眼角桃花
    2020-11-27 05:22

    Try uploading the file as form data

    audioRecorder.exportWAV(function(blob) {
    
          var url = (window.URL || window.webkitURL).createObjectURL(blob);
          console.log(url);
    
          var filename = ;
          var data = new FormData();
          data.append('file', blob);
    
          $.ajax({
            url :  "lib/vocal_render.php",
            type: 'POST',
            data: data,
            contentType: false,
            processData: false,
            success: function(data) {
              alert("boa!");
            },    
            error: function() {
              alert("not so boa!");
            }
          });
    }); 
    

    .

    
    

提交回复
热议问题