title: How to add file upload to spreadsheet as custom menu option?
body: <p>I want to make a spreadsheet CMS - that is to read/write data from firebase and vice versa. I reached a point where I need to upload files directly from the spreadsheet and not any other page.</p>
  
  <p>I have added a custom menu with a htmlService to output a template where the user may click and upload a file and that file must get handled in google script, but the problem is that I'm getting only the fake path of a file "c:/fakepath/avatar.png" and not a blob.</p>
  
  <p>my files in google script:</p>
  
  <p>upload.html</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
    &lt;head&gt;
      &lt;base target="_top"&gt;
      &lt;link rel="stylesheet" href="https://ssl.gstatic.com/docs/script/css/add-ons1.css"&gt;
    &lt;/head&gt;
    &lt;body&gt;
      &lt;div&gt;
          &lt;div id="progress" &gt;&lt;/div&gt;
  
          &lt;input type="file" name="upload" id="file"&gt;
          &lt;input type="submit" value="Submit" class="action" onclick="form_data()" &gt;
          &lt;input type="button" value="Close" onclick="google.script.host.close()" /&gt;
      &lt;/div&gt;
      &lt;script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"&gt;
      &lt;/script&gt;
      &lt;script&gt;
        function form_data(){
          var values = [{
            "file":$("#upload").val(),
          }];
  
          google.script.run.withSuccessHandler(closeIt).upload(values);
        };
  
        function closeIt(){
          google.script.host.close()
        };
      &lt;/script&gt;
    &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>test.gs</p>
  
  <pre><code>function upload(values){
    //Display the values submitted from the dialog box in the Logger. 
    Logger.log(values); // here I'm getting file = c/fakepath/avatar.png while I 
         //need the file to send it as a post request or save it in google drive
  };
  </code></pre>
  
  <p>I believe I should use FileReader but I have tried and failed:</p>
  
  <pre><code>      var file, 
          reader = new FileReader();
  
  // Upload the file to Google Drive
    reader.onloadend = function(e) {
      google.script.run
        .upload(
           e.target.result, file.name
        );
    };
        function form_data(){
      reader.readAsDataURL(file);
  }
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/AIsLY.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/AIsLY.png" alt="custom menu file upload"></a></p>