I try to upload single files and stack them in the same array but every time I do it, Its create a new array with same name , I like to be every time you add new file to record in this array so on submit to submit them all
<input type="file" name="file-input" multiple id="file-upload"/>
Jquery
var fileInput = document.getElementById('file-upload');
var fileList = [];
fileInput.addEventListener('change', function (event)
{
for (var i = 0; i < this.files.length; i++)
fileList.push(fileInput.files[i]);
{
console.log(fileInput.files)
}
});
multipleattribute set, so it can only “hold”/ select one single file at a time. So your for loop will run only one time each time you select a file as well. Not sure what you mean by “it open a new array” though.<input type="file" multiple="true" />? Then you get this exact behaviour by default, without need for JS