The following code inserts files from a file
field, into a FormData
:
var filedata = event.target; // FileList object
var i = 0, len = filedata.files.length, file;
for (; i < len; i++) {
file = filedata.files[i];
// ...
// Aqui adiciono o campo ao FormData
formData.append('img_upload_'+(countFiles++), file);
}
Question
Is it possible to remove a file / field previously added to FormData
, or do I have to create a new instance, and have the user add all the files again?
The above method is executed every time a modification happens (event onchange
) in a input
field of type file
. At the end, formData
will be sent by AJAX.