我是Meteor的新人。我试图找到一种上传文件的方法 我一步一步地使用fs集合跟随这个tuto:http://meteortuts.com/category/addanuploader 但是,它不起作用。没啥事儿!有什么遗失的吗? 我在本地尝试并在apps.meteor.com上部署它。 在" uploadexample.meteor.com ",出现错误,因为该网站无法识别"〜"字符。在本地,显示页面但没有上传任何内容。任何的想法? 谢谢你的回复,
Michelk 这是我的代码:
HTML:
<head>
<title>uploadexample</title>
</head>
<body>
<h1>Welcome to Meteor!</h1>
<div class="container">
{{> hello}}
</div>
</body>
<template name="hello">
<div class="panel panel-default push-down">
<div class="panel-heading">
<h3 class="panel-title">Uploads Section</h3>
</div>
<div class="panel-body">
<p>
Add Files
<span class="btn btn-default btn-file">
<input multiple type="file" name="file" class="file fileInput"/>
</span>
</p>
</div>
<div class="panel-footer">
<div class="col-md-9">
<table class="table table-hover table-striped table-bordered">
<thead>
<th>Name</th>
<th>Download</th>
</thead>
<tbody>
{{#each uploads}}
<tr>
<td>{{name}}</td>
<td><a href="{{url download=true}}" type="button" class="btn btn-default">
Download
</a></td>
</tr>
{{/each}}
</tbody>
</table>
</div>
</div>
</div>
</template>
js文件:
Uploads = new FS.Collection('uploads',{
stores:[new FS.Store.FileSystem('uploads',{path:'~/projectUploads'})]
});
if (Meteor.isClient) {
// counter starts at 0
Session.setDefault("counter", 0);
Template.hello.helpers({
counter: function () {
return Session.get("counter");
},
uploads:function(){
return Uploads.find();
}
});
Template.hello.events({
'change .fileInput':function(event,tmpl){
FS.Utility.eachFile(event,function(file){
var fileObj = new FS.File(file);
Uploads.insert(fileObj),function(err){
console.log(err);
}
})
}
});
}
if (Meteor.isServer) {
Meteor.startup(function () {
// code to run on server at startup
});
}
流星列表包:
...tuto meteor/upload fs/uploadexample$ meteor list
bootstrap 1.0.1 Front-end framework from Twitter
cfs:filesystem 0.1.1 Filesystem storage adapter for CollectionFS
cfs:standard-packages 0.5.3 Filesystem for Meteor, collectionFS
meteor-platform 1.2.1 Include a standard set of Meteor packages in your app
twbs:bootstrap 3.3.2 Bootstrap (official): the most popular HTML/CSS/JS framework for responsive, mobile first projects
答案 0 :(得分:2)
我一直在搜索与你相同的东西。当您的应用使用meteor
在本地运行时,它显然会使~/projectUploads
显示在您的本地主文件夹中。但是当您希望自己的应用在meteor托管meteor deploy example.meteor.com
上运行时,您应该修改./projectUploads
的路径。一切都应该工作正常。 手指交叉