使用Meteor处理文件上传的标准方法是什么?
发布于 2012-04-11 14:24:19
目前似乎没有一种方法可以与HTTP服务器交互或做任何与HTTP相关的事情。
您可以做的惟一事情就是通过Meteor.methods公开的RPC方法与服务器通信,或者通过公开的RPC直接与mongoDB通信。
发布于 2013-01-05 04:53:02
对于图像,我使用类似于Dario's的方法,只是我不将文件写入磁盘。我将数据作为模型上的一个字段直接存储在数据库中。这对我来说很有效,因为我只需要支持支持HTML5 File API的浏览器。我只需要简单的图像支持。
Template.myForm.events({
'submit form': function(e, template) {
e.preventDefault();
var file = template.find('input type=["file"]').files[0];
var reader = new FileReader();
reader.onload = function(e) {
// Add it to your model
model.update(id, { $set: { src: e.target.result }});
// Update an image on the page with the data
$(template.find('img')).attr('src', e.target.result);
}
reader.readAsDataURL(file);
}
});
发布于 2012-10-20 13:32:50
我刚刚想出了使用Meteor.methods和HTML5文件的应用程序接口的an implementation of file uploads。让我知道你的想法。
https://stackoverflow.com/questions/10099202
复制相似问题