(ca88亚洲城娱乐欢迎您) autoform + collection2实现上传失败

  • packages

 aldeed:collection2 cfs:standard-packages cfs:gridfs aldeed:autoform
  • html

<template name="profile">
{{#autoForm collection=Links type=insert id=insertLinksForm}} <fieldset> {{> afQuickField name=title}} {{> afQuickField name=picture}} <button type="submit" class="btn btn-primary">insert</button> </fieldset> {{/autoForm}}
</template>
  • lib/collections/images

//stores:[]
var Images = new FS.Collection"images",{ stores:[new FS.Store.GridFSimagesStore,{path:~/uploads}]
} Images.allow{ insert: functionuserId, doc { return true; }, update: functionuserId, doc, fieldNames, modifier { return true; }, download: functionuserId { return true; }
};`
  • lib/collection/link

Schemas = {};
//将Meteor.Collection改为Mongo.Collection,由于meteor版本的升级
var Links = new Mongo.Collectionlinks;
Schemas.Links = new SimpleSchema{ title:{ type:String, max:60, }, picture:{ type:String, autoform:{ afFieldInput:{ type:fileupload, collection:Images, label:上传 } } }
}
Links.attachSchemaSchemas.Links;
Links.allow{ insert:function { return true; }
}
  • publication

Meteor.publishimages, function { return Images.find{};
};
Meteor.publishlinks,function { return Links.find{}
}
  • error:link is not in window scope

求大神解答?

发表评论

电子邮件地址不会被公开。 必填项已用*标注