0

I need a input:file to upload files, but the user added files multi-time. At the end I need to upload all files the user select.

But I meet the problem, why I try to set the FileList. How to resize the Filelist object and input them another new file?

user504909
  • 9,119
  • 12
  • 60
  • 109

2 Answers2

0

If I understand your problem correctly, you want to keep selecting files by clicking the button multiple no. of times.

For that, you can do something like this:

  1. Add onchange event for input-file
  2. Maintain a hashtable (simply, an object) to hold all the selected files.
  3. Inside onchange event handler fill the hash table. (Note: depending upon your requirement, you may want to change how the 'key' is created for this hashtable).
<input type="file" multiple="multiple" id="fname" onchange="pp()" />​
<script type="text/javascript">
var x={};
function pp()
{
    var k = document.getElementById("fname");
    for (var i = 0; i < k.files.length; i++){
      x[k.files[i].name]=k.files[i];
    }
    console.log(x);
}
</script>
prashanth
  • 2,059
  • 12
  • 13
  • it do not useful. I also need to put the Filelist object back to input:file, because I need the input:file value to update the file form. Do you how to upload files object without input:file object? – user504909 Oct 05 '12 at 06:03
0

You can as well create another input file on top of your current one, and when the user will click on it another input file will open and the previous one will store previous files.

bluish
  • 26,356
  • 27
  • 122
  • 180
user1801180
  • 125
  • 1
  • 1
  • 5