0

This is my code...

What I want to do:

  1. Record the audio of the user save it as a blob
  2. Make the recorded audio equal to the value of the file input tag...

What I have achieved:

  1. Recording and converting to blob is done

How do I make the value of the input file tag equal to the blob?

mediaRecorder.addEventListener("stop", () => {
    const audioBlob = new Blob(audioChunks, { 'type' : 'audio/wav; codecs=MS_PCM' });
    const audioUrl = URL.createObjectURL(audioBlob);
    // document.querySelector('#id_audio').value = 'How to do this?';
});

Any help is highly appreciated!

Thanks a lot!

  • Does this answer your question? [How to set a value to a file input in HTML?](https://stackoverflow.com/questions/1696877/how-to-set-a-value-to-a-file-input-in-html) – Lars Flieger Apr 19 '21 at 11:38
  • I understand the security reasons... but in this case I am not taking any files from user's system, I want to make the value of the input equal to a blob which is an audio file recorded in the browser itself... –  Apr 19 '21 at 11:40
  • Alright check this: https://stackoverflow.com/questions/23511792/attach-a-blob-to-an-input-of-type-file-in-a-form/66466855#66466855 – Lars Flieger Apr 19 '21 at 11:42
  • 1
    Thanks a ton... You helped me a lot. I was struggling with this for a long time. –  Apr 19 '21 at 11:52
  • You're welcome :D – Lars Flieger Apr 19 '21 at 19:49

0 Answers0