Cannot upload image using autoform

Hi,

I create a form to upload image using autoform. i’ve succeed to insert it to my collection, but the image cannot be upload…

here is my code
Recipes = new Meteor.Collection('recipes');

Images = new FS.Collection("images", {
    stores: [new FS.Store.GridFS("filesStore", {path: "~/img/uploads"})]
});

Recipes.allow({
    insert : function (userId, doc) {
        return !!userId;
    },
    update: function (userId, doc) {
        return !!userId;
    }
});

Images.allow({
    insert: function(userId, doc) {
        return !!userId;
    },
    update: function (userId, doc) {
        return !!userId;
    }
});

RecipeSchema = new SimpleSchema({
    name : {
        type:String,
        label:'Menu'
    },
    pict : {
        type:String,
        label : 'Picture',
        autoform : {
            afFieldInput: {
                type: "cfs-file",
                collection: "images",
                onBeforeInsert : function () {
                    
                }
            }
        }
    },
    author : {
        type : String,
        label : 'Author',
        autoValue : function () {
            return this.userId
        },
        autoform : {
            type:'hidden'
        }
    }
});

Recipes.attachSchema(RecipeSchema);

i also got warning when i insert the data : The provided value ‘undefined’ is not a valid enum value of type XMLHttpRequestResponseType.

cfs is not longer maintain, i recommend meteor files or slingshot

Hi levalaroix,

i try timbrandin:autoform-slingshot… but when i select the image, i always get error in console log.
The error is invalid directive

you can see my link for the detail Autoform slingshot the directive does not seem exists

1 Like