moringaman
7/2/2016 - 5:56 PM

File Upload of UserImage data - FsGrid/Meteor

File Upload of UserImage data - FsGrid/Meteor

Template.profile.events({
    "submit .edit-profile": function(event){
      var file = $('#profileImage').get(0).files[0];

       if (file){
         fsFile = new FS.File(file);
         ProfileImages.insert(fsFile, function(err, result){
           if (err){
             throw new Meteor.Error(err);
           }else{
             var imageLoc = '/cfs/files/ProfileImages/'+result._id;

           UserImages.insert({
             userId:Meteor.userId(),
             username: Meteor.user().username,
             image: imageLoc,
             created: new Date()
           });
           Router.go('/');
         }

       });