Here is a way to append
file to FormData
:
var data = new FormData();
jQuery.each($('#file')[0].files, function(i, file) {
data.append('file-'+i, file);
});
is it possible to do as below ?
data[i].remove();???
or data[i] = file;??
how iIcan remove or modify a value from data
I know this thread is old but I just found this : https://developer.mozilla.org/en-US/docs/Web/API/FormData/delete
I'm sur it could help. You can use
formData.delete(name)
to delete the entry of formData with "name" key.You cannot do anything other than append items to a FormData object. See the Spec. It would be better if you use a dictionary/object to store all the values you want to add/modify before you actually construct the object.