Skip to content

Instantly share code, notes, and snippets.

@daslicht
Last active August 29, 2015 14:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save daslicht/fd41db7f115a20e07e52 to your computer and use it in GitHub Desktop.
Save daslicht/fd41db7f115a20e07e52 to your computer and use it in GitHub Desktop.
beforeFileUploadCallback: function(files, e) {
console.log(e);
var file = files[0];
var reader = new FileReader();
reader.onload = function(fileLoadEvent) {
Meteor.call('uploadImage', file, reader.result, function(error, vo) {
});
};
reader.readAsBinaryString(file);
return false;
}
-------
Meteor.methods({
uploadImage: function(file, data) {
var fs = Meteor.require('fs');
var fileName ='/home/daslicht/meteor/test/public/images/'+file.name;
fs.writeFile(fileName, data, function (err) {
if (err) throw err;
});
return true;
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment