I'm currently using Meteor collectionFS, to be able to upload images, the project works correctly, but it only works if I want to upload and see a single image. What I want is to select 2 or more images and to visualize correctly, in the input I am using the multiple attribute, but how do I see the images?
Client images.html
<template name="images">
<div align="center">
<form align="center" role="form">
<div>
<div>
<span class="btn btn-success btn-file">
<input type="file" accept=".gif,.jpg,.png" class="myFileInputimagepub" id="image" multiple/>
</span>
</div>
<div>
<img src="{{currentUser.photo.image}}" alt="Image" width="60px" height="60px" value=''/>
</div>
</div>
</form>
</div>
</template>
images.js
import './images.html';
Template.images.events({
'change .myFileInputimagepub':function(evt,tmpl){
FS.Utility.eachFile(event,function(file){
fileImagespub.insert(file,function(err,fileObj){
if(!err){
var userId = Meteor.userId();
var imageurl = {
‘photo.image':'/cfs/files/fileimages/' + fileObj._id
};
setTimeout(function(){
Meteor.users.update(userId,{$set:imageurl});
},200);
}
})
})
},
});
Server
permissions/ permissions.js
Meteor.users.allow({
insert:function(userId,doc){
return userId;
},
update:function(userId,doc,fields,modifier){
return userId && doc._id === userId;
},
remove:function(userId){
return userId;
}
});
fileImagespub.allow({
insert:function(){
return true;
},
update:function(){
return true;
},
remove:function(){
return true;
},
download:function(){
return true;
}
Both/collections/fileupload.js
var filepubimagestorage = new FS.Store.GridFS("fileimagesp");
fileImagespub = new FS.Collection("fileimages",{
stores:[filepubimagestorage]
});