JQuery: Push FormData?

Is there a way to add additional data to the formdata element that handles file upload? I know that formdata does not support .push ()?

$("frm").submit(function (e) {
 e.preventDefault();
 var data = new FormData($(this)[0]);

 });
+4
source share
1 answer

If I understand your question correctly, you want to add additional keys and values ​​to the FormData object after them from the form. If yes, then yes! He uses the method append:

data.append('SomeField', 'SomeValue');

You can do this with a string or with a tag Blobor Filethat suits you.

This is described on the page.

+5
source

Source: https://habr.com/ru/post/1542083/


All Articles