Skip to content
This repository has been archived by the owner on Mar 14, 2019. It is now read-only.

Insert One or More Files From File Input

Philipp edited this page Mar 1, 2015 · 2 revisions

In client code:

Template.myForm.events({
  'change .myFileInput': function(event, template) {
    FS.Utility.eachFile(event, function(file) {
      Images.insert(file, function (err, fileObj) {
        //If !err, we have inserted new doc with ID fileObj._id, and
        //kicked off the data upload using HTTP
      });
    });
  }
});

Note that this works regardless of whether the file input accepts multiple files.