-2

HTML:

<div class="filesdiv">
        <input type="file" name="files" id="files" style="display: none;" multiple 
      required>
        <label for="files" class="btn btn-xs">Upload files</label>
        <div class="filenames"></div>
</div>

JQUERY:

var filelist = [];

$('#files').change(function(event) {
    files = this.files;
    console.log(files);
    filelist.push(files);
    console.log(filelist[0]);
    $('.filenames').empty()
    $.each(files, function(index) {
        $('.filenames').append('<div style="overflow: hidden;">'+this.name+'</div>');
    });
    $('#files').val('')
    console.log(this.files)
    console.log(filelist[0])
});

My consoles output:

console.output

My basic need is to delete a single file from multiple input. I have read few stackoverflow answers and blogs that, files are in FileList Object and it is read only. So, I am trying to make a local copy and try to manipulate it. Once the FileList object is deleted so is the array filelist.

Yogi
  • 1,561
  • 5
  • 26
  • 45

1 Answers1

0

You may want to use a lib to make life easier.

Some thing like uploadify: http://www.uploadify.com/documentation/uploadifive/implementing-uploadifive/

Jack Luo
  • 333
  • 3
  • 5