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.GridFS('imagesStore',{path:'~/uploads'})]
}

)
Images.allow({
  insert: function(userId, doc) {
    return true;
  },
  update: function(userId, doc, fieldNames, modifier) {
    return true;
  },
  download: function(userId) {
    return true;
  }
});`
  • lib/collection/link

Schemas = {};
//将Meteor.Collection改为Mongo.Collection,由于meteor版本的升级
var Links = new Mongo.Collection('links');
Schemas.Links = new SimpleSchema({
  title:{
    type:String,
    max:60,
  },
  picture:{
    type:String,
    autoform:{
      afFieldInput:{
        type:'fileupload',
        collection:'Images',
        label:'上传'
      }
    }

  }
})
Links.attachSchema(Schemas.Links);
Links.allow({
  insert:function () {
    return true;
  }
})
  • publication

Meteor.publish('images', function() {
  return Images.find({});
});
Meteor.publish('links',function () {
  return Links.find({})
})
  • error:link is not in window scope

求大神解答?

阅读 2.2k
1 个回答
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题