title: Google Script for Uploading File Not Working
body: <p>I wrote a script for uploading files to my Google Drive using the Google Script. I deployed it as a WebApp but it's not working and I don't know why. The button just gets stuck on "Subiendo..." and never changes anything inside my Drive. I'm sure I gave the script all the permissions and I already tried to see what's happening on my own without any sucess. Can you maybe help me find what should I do? I post the code here:</p>
  
  <p><strong>Code.gs</strong></p>
  
  <pre><code>function doGet() {
      return    HtmlService.createHtmlOutputFromFile('main').setSandboxMode(HtmlService.SandboxMode.IFRAME);
  }
  
  function serverFunc(theForm) {
      try{
          var folder_name = "publicaciones";
          var folder,folders = DriveApp.getFoldersByName(folder_name);
  
          if(folders.hasNext()){
               folder = folders.next();
          }else{
               folder = DriveApp.createFolder(folder_name);
          }
          Logger.log("TheForm", theForm == null);
          var blob = theForm.theFile;
          Logger.log("Blob!", blob == null);
          var file = folder.createFile(blob);
          Logger.log("File:", file.getName());
          return "Archivo subido exitosamente: " + file.getUrl();
  
       } catch(error){
          Logger.log("error: ", error.toString());
          return error.toString();    
    }
  }
  </code></pre>
  
  <p>** main.html **</p>
  
  <pre><code>&lt;div&gt;
  &lt;form id="myForm"&gt;
     &lt;input type="file" name="theFile"&gt;
     &lt;input type="hidden" name="anExample"&gt;
     &lt;br&gt;
     &lt;input type="button" value="Subir Archivo" onclick="this.value='Subiendo...';
                                                         google.script.run.withSuccessHandler(fileUploaded).serverFunc(this.parentNode);
                                                         return false;"&gt;
  &lt;/form&gt;
  &lt;/div&gt;
  &lt;div id="output"&gt;
  &lt;/div&gt;
  
  &lt;script&gt;
      function fileUploaded(status) {
          document.getElementById('myForm').style.display = 'none';
          document.getElementById('output').innerHTML = status;
      }
  &lt;/script&gt;
  </code></pre>
  
  <p>I'd appreaciate any help or pointers you can give me. Thanks a lot!</p>