javascript - Pass file across route in Meteor -


one 1 page, have file selector input. when user selects file, user directed separate route contains interactive image cropper used prepare image before upload server. since able use button escape cropper, makes sense in separate route. using iron-router this.

template.mytemplate.events({     'change input[type="file"]': function(e, t) {         router.go('crop');     } }); 

this takes me crop page. @ point though not sure how file reference mytemplate crop. code below using draw uploaded image canvas when in same template.

var reader = new filereader(); reader.onload = function(e) {     img = new image();     img.onload = function() {          //draw image canvas element     };     img.src = e.target.result; }; reader.readasdataurl(e.target.files[0]); 

i need find way transfer file reference when change routes.

you not gonna able file reference mytemplate crop template. call crop template, template unload , not available anymore.

on change event, can store file reference variable in application scope. , call crop template.

on top of template file:, or client/app.js

var myfile; 

into change event:

template.mytemplate.events({   'change input[type="file"]': function(e, t) {    myfile = e.currenttarget.files[0];     router.go('crop');    }  }); 

into crop route, use myfile variable wherever want!


Comments

Popular posts from this blog

apache - PHP Soap issue while content length is larger -

asynchronous - Python asyncio task got bad yield -

javascript - Complete OpenIDConnect auth when requesting via Ajax -