0

How do I pass additional parameters to a load event? Here is an example of what I'm trying to do.

var imageID = 'this-is-my-img-id';
var image;

reader = new FileReader();
reader.onload = function(e, imageID, image){

    image = '<img src="'+e.target.result+' id="'+imageID+'" >';

}

reader.readAsDataURL(file);
user2287474
  • 626
  • 2
  • 8
  • 14
  • 1
    You cannot. However due to how scoping works in Javascript, the `image` vbariable defined in line `2` is available inside the anyonymous function defined for `onload`, and you can just read it, without passig it as an argument – Johannes H. Jun 09 '16 at 03:07
  • What is the purpose of `image` variable? – Ivan Nevostruev Jun 09 '16 at 03:13

0 Answers0