title: Upload file with google apps script using html service
body: <p>I want to upload a file using the HtmlService of GAS but it doesn't work. 
  I found informations in this topic <a href="https://stackoverflow.com/questions/15670392/uploading-file-using-google-apps-script-using-htmlservice">Uploading file using Google Apps Script using HtmlService</a> but it doesn't fit with my issue.
  Here is an example that describes my problem:</p>
  
  <p><strong>Code.gs:</strong></p>
  
  <pre><code>    function doGet() {
  
      return HtmlService.createTemplateFromFile("index").evaluate();
  
      }
  
      //For some reasons, this function has to be in code.gs
      funcion getHTML() {
  
          var html = "&lt;form id='myform'&gt;"+
                       "&lt;input name='myfile'&gt;"+
                     "&lt;/form&gt;"+
                     "&lt;div data-formname='myform'&gt; Submit form &lt;/div&gt;";
  
      return html;
  
      }
  
      function uploadFile(file) {
  
        DriveApp.createFile(file); *//Doesn't work :/*
  
      }
  </code></pre>
  
  <p><strong>Javascript:</strong></p>
  
  <pre><code>    $(document).on("click","div", function(e) {
  
      var idform = $(this).data("formname");
  
      if (idform) 
      sendForm(idform);
  
  
      });
  
  function trigger() {
  
  google.script.run.withsuccesshandler(setHTML).getHTML();
  
  }
  
  function setHTML(html) {
  
  $("#myHTML").html(html);
  
  }
  
  function sendForm(idForm) {
  
  var formElements = document.getElementById("idForm").elements;
  var form = {};
  
  for (var key in formElements) form[key] = formElements[key];
  
  google.script.run.withsuccesshandler().uploadFile(form["myfile"]);
  
  }
  </code></pre>
  
  <p><strong>index.html</strong>    </p>
  
  <pre><code>&lt;body onload="trigger()"&gt;
  
  &lt;div id='myHTML'&gt;&lt;/div&gt;
  
  &lt;/body&gt;
  </code></pre>