Answer the question
In order to leave comments, you need to log in
How to put a temporary file using js in input type=file?
Implemented sound recording on the site, after the recording is stopped, the file is saved to temporary storage. How to send this file to the form? I tried to send ajax directly to the server, but this is not quite what I need.
Answer the question
In order to leave comments, you need to log in
Suppose your sound file is in the blob variable, then you can insert it into the field like this:
// Создаем коллекцию:
var dt = new DataTransfer();
dt.items.add(new File([blob], 'FileName.wav', {type: blob.type}));
var file_list = dt.files;
console.log('Коллекция файлов создана:');
console.dir(file_list);
// Вставим созданную коллекцию в реальное поле:
document.querySelector('input[type="file"]').files = file_list;
I tried to send ajax directly to the server, but this is not quite what I need
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question