I am trying make an html5 image uploader but html5 has problems with multiple upload.
This is the script I use:
function makeFileList() {
var input = document.getElementById("filez");
var ul = document.getElementById("file_wrap_list");
while (ul.hasChildNodes()) {
ul.removeChild(ul.firstChild);
}
for (var i = 0; i < input.files.length; i++) {
var j = i+1;
var li = document.createElement("li");
li.innerHTML = j+'. '+input.files[i].name;
ul.appendChild(li);
}
if(!ul.hasChildNodes()) {
var li = document.createElement("li");
li.innerHTML = 'No Files Selected';
ul.appendChild(li);
}
}
the HTML tag:
<input type="file" name="photo[]" id="filez" multiple onchange="makeFileList();"/>
then on submit I upload and add the images in mysql table. I thought about chaning the js script so that every time iamges are selected they are going to create hidden inputs and normally show their names so that clients know what they have selected. and then after submiting the form the images are going to be uploaded, but I don't know if it is going to work in practice and my idea seems a bit odd. I would like to know if anyone has any suggestion on how to alter the js script so that everytime a user clicks and selectes images the script to register the images in array. Or any other idea is welcome.