Last active
August 29, 2015 14:01
-
-
Save daslicht/fd41db7f115a20e07e52 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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