How can javascript upload a blob?

前端 未结 6 2265
旧时难觅i
旧时难觅i 2020-11-22 11:29

I have a blob data in this structure:

Blob {type: \"audio/wav\", size: 655404, slice: function}
size: 655404
type: \"audio/wav\"
__proto__: Blob
6条回答
  •  醉话见心
    2020-11-22 12:06

    Try this

    var fd = new FormData();
    fd.append('fname', 'test.wav');
    fd.append('data', soundBlob);
    $.ajax({
        type: 'POST',
        url: '/upload.php',
        data: fd,
        processData: false,
        contentType: false
    }).done(function(data) {
           console.log(data);
    });
    

    You need to use the FormData API and set the jQuery.ajax's processData and contentType to false.

提交回复
热议问题