N
N
Nadim Zakirov2020-05-07 14:51:41
JavaScript
Nadim Zakirov, 2020-05-07 14:51:41

How to get Blob from input[type="files"]?

I want to attach a file to the constructed form:

var formData = new FormData();
... // Тут создаю нужные мне поля
formData.append("file", Blob, "test.mp3");

However, in order to do this, I first need to get my hands on the Blob.
Tell me, how can I pull out Blob from the input field with the inserted file?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Dmitry Belyaev, 2020-05-07
@zkrvndm

https://developer.mozilla.org/ru/docs/Web/API/File
File inherited from Blob

A
Andrey Pastukhov, 2020-05-07
@tyllo

And why exactly Blob?

const file = document.querySelector('input[type="files"]').value;
formData.append("file", file, "test.mp3");

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question