javascript - How to Upload an Image to Server on Meteor Startup -


i trying set default dp users not have/not uploded image.

tried using helpers display content getting error "uncaught error: {{#each}} accepts arrays, cursors or falsey values." code below(client js) js :

template.mcomments.helpers({     'mcommentsdata':function(){       return comdata.find({},{sort:{"at":-1}}).fetch();     },      images2: function () {         var fetchimg=meteor.users.findone({             "_id":this.__id           });          if((fetchimg.profileimage==undefined)||(fetchimg.profileimage=="")){         var hello="/images/prof.jpg"         return hello;         }else{             return images.find({"_id":fetchimg.profileimage})           }     }   }); 

html

    <template name="mcomments"> <div id="mcomments" class="col-lg-3">     <div><h5 class="mcommentsheader">followup stream </h5>     </div>     <div class="col-lg-12 scrolling comscrolllist" id="mcomments1">         <div id="mcomments2">             {{#each mcommentsdata}}             <div class="col-lg-12 comcontainer">                 <div class="row">                     <div class="col-lg-3 indcomments" >                         {{#each images2}}                         <img src="{{this.url                         }}" width="45px" height="50px" alt="">                         {{/each}}                     </div>                     <div class="col-lg-9" style="">                         <div class="row combody" >                             <div class="pull-left mcommfont" >{{user}}</div>                             <div class="pull-right mcommcust">{{product}} case#{{productcaseno}}</div>                         </div>                         <div class="maincomment">{{comment}}</div>                         <div class="comtemp"> <span data-livestamp="{{at}}"></span></div>                     </div>                 </div>             </div>              <div class="col-lg-12 comblankspace">             </div>             {{/each}}         </div>     </div> </div> </template> 

now have given on approach , thinking of uploading image , attaching url profiles default(oncreateuser) until change it.i believe might have upload , image automatically on server startup. please lead me right direction still noob in meteor.

storage adapter: gridfs.

regards, azaruddin

change 'hello' variable following code:

var hello = [     { url: "/images/prof.jpg" } ]; 

you're running problems because hello string - #each expects array/cursor/etc. error suggests.

alternatively, use {{#else}} on each block , rid of returning 'hello' case entirely:

{{#each images}}     ... {{else}}     <!-- default profile image code --> {{/each}} 

Comments