3
The following code inserts files from a field file
, in 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
It is possible to remove a file/field previously added to FormData
, or 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 occurs (event onchange
) in a field input
of the kind file
. At the end, formData
will be sent by AJAX.
Yes, I had already started making modifications to work this way. Soon put whether it worked or not.
– Calebe Oliveira
Yes, after a lot of effort with Javascript and a few hours of debugging, I was able to make it work. I added drag & drop support as well.
– Calebe Oliveira
Glad you decided! @Calebeoliveira
– bfavaretto