   @selected_files = new ReactiveVar()
   @selected_files.set([])
 
+  @payload = new ReactiveVar()
+
+  @upload_ready = new ReactiveVar()
+  @upload_ready.set( false )
+
   # prevent dropping files onto page creating navigation
   # http://stackoverflow.com/a/6756680/1633026
   window.addEventListener 'dragover', ((e) ->


Template.InsertImageDialog.events
  "change #insert_image": (event, template) ->
    div = template.find("#preview")
    $(div).empty()
    append_spinner(div)

      actual_width = opts.full_image.width*scale

    thumb = getThumbnail(opts.full_image, scale)
    payload.thumb_canvas = thumb

    div = template.find("#preview")
    $(div).empty()
    div.appendChild(thumb)
  template.payload.set( payload )
  template.upload_ready.set( true )

handle_files = (fileList, template) ->
  # template is template instance of InsertImageDialog
