gpt4 book ai didi

meteor :将文件上传到文件夹

转载 作者:行者123 更新时间:2023-12-02 01:41:39 24 4
gpt4 key购买 nike

我是 Meteor 的新手。我试图找到一种上传文件的方法我逐步使用 fs 集合遵循了这个教程:http://meteortuts.com/category/addanuploader但是,它不起作用。什么都没发生!有什么东西不见了吗?我在本地尝试过并在 apps.meteor.com 上部署它。在“ uploadexample.meteor.com ”上,出现错误,因为该站点无法识别“~”字符。在本地,显示页面但未上传任何内容。任何的想法?感谢您的回复,

米歇尔克这是我的代码:

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
});
}

meteor 列表包:

...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

最佳答案

我一直在搜索与您的类似的东西。当您的应用程序使用 meteor 在本地运行时,它确实会使 ~/projectUploads 显然进入您的本地主文件夹。但是,当您希望您的应用程序在 meteor 托管 meteor deploy example.meteor.com 上运行时,您应该将路径编辑为 ./projectUploads。一切都应该工作正常。 双手合十

关于 meteor :将文件上传到文件夹,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28174389/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com