File Upload Queue

File Upload Queue

I am trying to make an upload queue that I can submit multible photos to a PHP file for handling. I know how to submit a form, and send stuff through Ajax, but the file upload has me stumped. I know there are many out there such as BlueImp, but I am having issues with blueimp once my security is in place. I also need it to do some things, that it cannot do. However, I do like the way it works, I have also looked at other JQuery uploaders, that build a file list, but cannot figure out how it comes together.

It seems like I am on the right track with:
var filesList = new Array();
$("input:file").change(function () {
filesList.push(this.files);
for (var i = 0; i < this.files.length; i++) {

var newTextBoxDiv = $(document.createElement('div')).attr("id", 'TextBoxDiv');

newTextBoxDiv.after().html('<input type="text" name="PhotoText[]" />');

newTextBoxDiv.appendTo("#Files");
}

});

The issue seems to be when adding a another round of files. Say the user first selects two files, the array adds the files in fine. Then the user, goes to add more files, the array gets wiped out, even though, the array is created outside of the change function.

Is there a better way of building an upload list, to do what I need, keep adding files as the user needs, then send it off for the magic.

Thanks,

Dave